Auto merge of #13985 - Veykril:content-modified, r=Veykril
Don't respond with a ContentModified while loading the workspace Initially this was done to prevent frequent inlay hint flickering, but this causes a lot of problems for a bunch of clients. We can (and already kind of have) move this into the semantic token request handlers instead. Fixes https://github.com/rust-lang/rust-analyzer/issues/10910
This commit is contained in:
commit
6e52c64031
@ -1438,6 +1438,10 @@ impl Config {
|
|||||||
try_or_def!(self.caps.workspace.as_ref()?.code_lens.as_ref()?.refresh_support?)
|
try_or_def!(self.caps.workspace.as_ref()?.code_lens.as_ref()?.refresh_support?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn inlay_hints_refresh(&self) -> bool {
|
||||||
|
try_or_def!(self.caps.workspace.as_ref()?.inlay_hint.as_ref()?.refresh_support?)
|
||||||
|
}
|
||||||
|
|
||||||
pub fn insert_replace_support(&self) -> bool {
|
pub fn insert_replace_support(&self) -> bool {
|
||||||
try_or_def!(
|
try_or_def!(
|
||||||
self.caps
|
self.caps
|
||||||
|
@ -1470,7 +1470,8 @@ pub(crate) fn handle_semantic_tokens_full(
|
|||||||
|
|
||||||
let mut highlight_config = snap.config.highlighting_config();
|
let mut highlight_config = snap.config.highlighting_config();
|
||||||
// Avoid flashing a bunch of unresolved references when the proc-macro servers haven't been spawned yet.
|
// Avoid flashing a bunch of unresolved references when the proc-macro servers haven't been spawned yet.
|
||||||
highlight_config.syntactic_name_ref_highlighting = !snap.proc_macros_loaded;
|
highlight_config.syntactic_name_ref_highlighting =
|
||||||
|
snap.workspaces.is_empty() || !snap.proc_macros_loaded;
|
||||||
|
|
||||||
let highlights = snap.analysis.highlight(highlight_config, file_id)?;
|
let highlights = snap.analysis.highlight(highlight_config, file_id)?;
|
||||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||||
@ -1493,7 +1494,8 @@ pub(crate) fn handle_semantic_tokens_full_delta(
|
|||||||
|
|
||||||
let mut highlight_config = snap.config.highlighting_config();
|
let mut highlight_config = snap.config.highlighting_config();
|
||||||
// Avoid flashing a bunch of unresolved references when the proc-macro servers haven't been spawned yet.
|
// Avoid flashing a bunch of unresolved references when the proc-macro servers haven't been spawned yet.
|
||||||
highlight_config.syntactic_name_ref_highlighting = !snap.proc_macros_loaded;
|
highlight_config.syntactic_name_ref_highlighting =
|
||||||
|
snap.workspaces.is_empty() || !snap.proc_macros_loaded;
|
||||||
|
|
||||||
let highlights = snap.analysis.highlight(highlight_config, file_id)?;
|
let highlights = snap.analysis.highlight(highlight_config, file_id)?;
|
||||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||||
@ -1524,7 +1526,12 @@ pub(crate) fn handle_semantic_tokens_range(
|
|||||||
let text = snap.analysis.file_text(frange.file_id)?;
|
let text = snap.analysis.file_text(frange.file_id)?;
|
||||||
let line_index = snap.file_line_index(frange.file_id)?;
|
let line_index = snap.file_line_index(frange.file_id)?;
|
||||||
|
|
||||||
let highlights = snap.analysis.highlight_range(snap.config.highlighting_config(), frange)?;
|
let mut highlight_config = snap.config.highlighting_config();
|
||||||
|
// Avoid flashing a bunch of unresolved references when the proc-macro servers haven't been spawned yet.
|
||||||
|
highlight_config.syntactic_name_ref_highlighting =
|
||||||
|
snap.workspaces.is_empty() || !snap.proc_macros_loaded;
|
||||||
|
|
||||||
|
let highlights = snap.analysis.highlight_range(highlight_config, frange)?;
|
||||||
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
let semantic_tokens = to_proto::semantic_tokens(&text, &line_index, highlights);
|
||||||
Ok(Some(semantic_tokens.into()))
|
Ok(Some(semantic_tokens.into()))
|
||||||
}
|
}
|
||||||
|
@ -307,6 +307,11 @@ impl GlobalState {
|
|||||||
if self.config.code_lens_refresh() {
|
if self.config.code_lens_refresh() {
|
||||||
self.send_request::<lsp_types::request::CodeLensRefresh>((), |_, _| ());
|
self.send_request::<lsp_types::request::CodeLensRefresh>((), |_, _| ());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Refresh inlay hints if the client supports it.
|
||||||
|
if self.config.inlay_hints_refresh() {
|
||||||
|
self.send_request::<lsp_types::request::InlayHintRefreshRequest>((), |_, _| ());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!was_quiescent || state_changed || memdocs_added_or_removed)
|
if (!was_quiescent || state_changed || memdocs_added_or_removed)
|
||||||
@ -606,8 +611,8 @@ impl GlobalState {
|
|||||||
Ok(())
|
Ok(())
|
||||||
});
|
});
|
||||||
|
|
||||||
if let RequestDispatcher { req: Some(req), global_state: this } = &mut dispatcher {
|
match &mut dispatcher {
|
||||||
if this.shutdown_requested {
|
RequestDispatcher { req: Some(req), global_state: this } if this.shutdown_requested => {
|
||||||
this.respond(lsp_server::Response::new_err(
|
this.respond(lsp_server::Response::new_err(
|
||||||
req.id.clone(),
|
req.id.clone(),
|
||||||
lsp_server::ErrorCode::InvalidRequest as i32,
|
lsp_server::ErrorCode::InvalidRequest as i32,
|
||||||
@ -615,16 +620,7 @@ impl GlobalState {
|
|||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
_ => (),
|
||||||
// Avoid flashing a bunch of unresolved references during initial load.
|
|
||||||
if this.workspaces.is_empty() && !this.is_quiescent() {
|
|
||||||
this.respond(lsp_server::Response::new_err(
|
|
||||||
req.id.clone(),
|
|
||||||
lsp_server::ErrorCode::ContentModified as i32,
|
|
||||||
"waiting for cargo metadata or cargo check".to_owned(),
|
|
||||||
));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatcher
|
dispatcher
|
||||||
|
Loading…
x
Reference in New Issue
Block a user