Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

language_selector: Fix debug_assert firing off on context menu creation for LSP view (#19854)

Piotr Osiewicz052b746fbd66
diff --git a/crates/language_tools/src/lsp_log.rs b/crates/language_tools/src/lsp_log.rs
index a5f77ec55f1..e57d5dbc4a2 100644
--- a/crates/language_tools/src/lsp_log.rs
+++ b/crates/language_tools/src/lsp_log.rs
@@ -1237,21 +1237,29 @@ impl Render for LspLogToolbarItemView {
view.show_rpc_trace_for_server(row.server_id, cx);
}),
);
- menu = menu.entry(
- SERVER_CAPABILITIES,
- None,
- cx.handler_for(&log_view, move |view, cx| {
- view.show_capabilities_for_server(row.server_id, cx);
- }),
- );
if server_selected && row.selected_entry == LogKind::Rpc {
let selected_ix = menu.select_last();
+ // Each language server has:
+ // 1. A title.
+ // 2. Server logs.
+ // 3. Server trace.
+ // 4. RPC messages.
+ // 5. Server capabilities
+ // Thus, if nth server's RPC is selected, the index of selected entry should match this formula
+ let _expected_index = ix * 5 + 3;
debug_assert_eq!(
- Some(ix * 4 + 3),
+ Some(_expected_index),
selected_ix,
"Could not scroll to a just added LSP menu item"
);
}
+ menu = menu.entry(
+ SERVER_CAPABILITIES,
+ None,
+ cx.handler_for(&log_view, move |view, cx| {
+ view.show_capabilities_for_server(row.server_id, cx);
+ }),
+ );
}
menu
})