chore: Fix several style lints (#17488)
It's not comprehensive enough to start linting on `style` group, but hey, it's a start. Release Notes: - N/A
This commit is contained in:
parent
93249fc82b
commit
e6c1c51b37
361 changed files with 3530 additions and 3587 deletions
|
@ -180,13 +180,13 @@ pub(crate) struct LogMenuItem {
|
|||
actions!(debug, [OpenLanguageServerLogs]);
|
||||
|
||||
pub fn init(cx: &mut AppContext) {
|
||||
let log_store = cx.new_model(|cx| LogStore::new(cx));
|
||||
let log_store = cx.new_model(LogStore::new);
|
||||
|
||||
cx.observe_new_views(move |workspace: &mut Workspace, cx| {
|
||||
let project = workspace.project();
|
||||
if project.read(cx).is_local_or_ssh() {
|
||||
log_store.update(cx, |store, cx| {
|
||||
store.add_project(&project, cx);
|
||||
store.add_project(project, cx);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -215,37 +215,34 @@ impl LogStore {
|
|||
let copilot_subscription = Copilot::global(cx).map(|copilot| {
|
||||
let copilot = &copilot;
|
||||
cx.subscribe(copilot, |this, copilot, inline_completion_event, cx| {
|
||||
match inline_completion_event {
|
||||
copilot::Event::CopilotLanguageServerStarted => {
|
||||
if let Some(server) = copilot.read(cx).language_server() {
|
||||
let server_id = server.server_id();
|
||||
let weak_this = cx.weak_model();
|
||||
this.copilot_log_subscription =
|
||||
Some(server.on_notification::<copilot::request::LogMessage, _>(
|
||||
move |params, mut cx| {
|
||||
weak_this
|
||||
.update(&mut cx, |this, cx| {
|
||||
this.add_language_server_log(
|
||||
server_id,
|
||||
MessageType::LOG,
|
||||
¶ms.message,
|
||||
cx,
|
||||
);
|
||||
})
|
||||
.ok();
|
||||
},
|
||||
));
|
||||
this.add_language_server(
|
||||
LanguageServerKind::Global {
|
||||
name: LanguageServerName(Arc::from("copilot")),
|
||||
if let copilot::Event::CopilotLanguageServerStarted = inline_completion_event {
|
||||
if let Some(server) = copilot.read(cx).language_server() {
|
||||
let server_id = server.server_id();
|
||||
let weak_this = cx.weak_model();
|
||||
this.copilot_log_subscription =
|
||||
Some(server.on_notification::<copilot::request::LogMessage, _>(
|
||||
move |params, mut cx| {
|
||||
weak_this
|
||||
.update(&mut cx, |this, cx| {
|
||||
this.add_language_server_log(
|
||||
server_id,
|
||||
MessageType::LOG,
|
||||
¶ms.message,
|
||||
cx,
|
||||
);
|
||||
})
|
||||
.ok();
|
||||
},
|
||||
server.server_id(),
|
||||
Some(server.clone()),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
));
|
||||
this.add_language_server(
|
||||
LanguageServerKind::Global {
|
||||
name: LanguageServerName(Arc::from("copilot")),
|
||||
},
|
||||
server.server_id(),
|
||||
Some(server.clone()),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
})
|
||||
});
|
||||
|
@ -593,21 +590,19 @@ impl LspLogView {
|
|||
});
|
||||
let events_subscriptions = cx.subscribe(&log_store, |log_view, _, e, cx| match e {
|
||||
Event::NewServerLogEntry { id, entry, kind } => {
|
||||
if log_view.current_server_id == Some(*id) {
|
||||
if *kind == log_view.active_entry_kind {
|
||||
log_view.editor.update(cx, |editor, cx| {
|
||||
editor.set_read_only(false);
|
||||
let last_point = editor.buffer().read(cx).len(cx);
|
||||
editor.edit(
|
||||
vec![
|
||||
(last_point..last_point, entry.trim()),
|
||||
(last_point..last_point, "\n"),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
editor.set_read_only(true);
|
||||
});
|
||||
}
|
||||
if log_view.current_server_id == Some(*id) && *kind == log_view.active_entry_kind {
|
||||
log_view.editor.update(cx, |editor, cx| {
|
||||
editor.set_read_only(false);
|
||||
let last_point = editor.buffer().read(cx).len(cx);
|
||||
editor.edit(
|
||||
vec![
|
||||
(last_point..last_point, entry.trim()),
|
||||
(last_point..last_point, "\n"),
|
||||
],
|
||||
cx,
|
||||
);
|
||||
editor.set_read_only(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
@ -877,8 +872,8 @@ fn log_filter<T: Message>(line: &T, cmp: <T as Message>::Level) -> Option<&str>
|
|||
|
||||
fn log_contents<T: Message>(lines: &VecDeque<T>, cmp: <T as Message>::Level) -> String {
|
||||
let (a, b) = lines.as_slices();
|
||||
let a = a.into_iter().filter_map(move |v| log_filter(v, cmp));
|
||||
let b = b.into_iter().filter_map(move |v| log_filter(v, cmp));
|
||||
let a = a.iter().filter_map(move |v| log_filter(v, cmp));
|
||||
let b = b.iter().filter_map(move |v| log_filter(v, cmp));
|
||||
a.chain(b).fold(String::new(), |mut acc, el| {
|
||||
acc.push_str(el);
|
||||
acc.push('\n');
|
||||
|
@ -1275,6 +1270,12 @@ const RPC_MESSAGES: &str = "RPC Messages";
|
|||
const SERVER_LOGS: &str = "Server Logs";
|
||||
const SERVER_TRACE: &str = "Server Trace";
|
||||
|
||||
impl Default for LspLogToolbarItemView {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl LspLogToolbarItemView {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
|
|
@ -53,7 +53,7 @@ async fn test_lsp_logs(cx: &mut TestAppContext) {
|
|||
},
|
||||
);
|
||||
|
||||
let log_store = cx.new_model(|cx| LogStore::new(cx));
|
||||
let log_store = cx.new_model(LogStore::new);
|
||||
log_store.update(cx, |store, cx| store.add_project(&project, cx));
|
||||
|
||||
let _rust_buffer = project
|
||||
|
|
|
@ -249,24 +249,23 @@ impl SyntaxTreeView {
|
|||
}
|
||||
|
||||
let node = cursor.node();
|
||||
return row
|
||||
.child(if node.is_named() {
|
||||
Label::new(node.kind()).color(Color::Default)
|
||||
} else {
|
||||
Label::new(format!("\"{}\"", node.kind())).color(Color::Created)
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.child(Label::new(format_node_range(node)).color(Color::Muted))
|
||||
.pl_1(),
|
||||
)
|
||||
.text_bg(if selected {
|
||||
colors.element_selected
|
||||
} else {
|
||||
Hsla::default()
|
||||
})
|
||||
.pl(rems(depth as f32))
|
||||
.hover(|style| style.bg(colors.element_hover));
|
||||
row.child(if node.is_named() {
|
||||
Label::new(node.kind()).color(Color::Default)
|
||||
} else {
|
||||
Label::new(format!("\"{}\"", node.kind())).color(Color::Created)
|
||||
})
|
||||
.child(
|
||||
div()
|
||||
.child(Label::new(format_node_range(node)).color(Color::Muted))
|
||||
.pl_1(),
|
||||
)
|
||||
.text_bg(if selected {
|
||||
colors.element_selected
|
||||
} else {
|
||||
Hsla::default()
|
||||
})
|
||||
.pl(rems(depth as f32))
|
||||
.hover(|style| style.bg(colors.element_hover))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,6 +405,12 @@ impl Item for SyntaxTreeView {
|
|||
}
|
||||
}
|
||||
|
||||
impl Default for SyntaxTreeToolbarItemView {
|
||||
fn default() -> Self {
|
||||
Self::new()
|
||||
}
|
||||
}
|
||||
|
||||
impl SyntaxTreeToolbarItemView {
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue