mirror of
https://github.com/helix-editor/helix.git
synced 2025-04-02 02:17:44 +03:00
LSP: Avoid requesting document colors for ghost transactions
The point of ghost transactions is to avoid notifying language servers about changes since the change is meant to be temporary. This is used for completion while selecting items in the menu: updating the language server would mess up incomplete completions. When a document is changed by a ghost transaction the language server will not be notified so its understanding of the document will not be synchronized and any positions it sends may be out-of-date. So we should avoid triggering a request for new document color information when a document is changed by a ghost transaction.
This commit is contained in:
parent
04d1180a0c
commit
d43de14807
1 changed files with 8 additions and 4 deletions
|
@ -167,10 +167,14 @@ pub(super) fn register_hooks(handlers: &Handlers) {
|
|||
apply_color_swatch_changes(color_swatches_padding);
|
||||
}
|
||||
|
||||
// Cancel the ongoing request, if present.
|
||||
event.doc.color_swatch_controller.cancel();
|
||||
|
||||
helix_event::send_blocking(&tx, DocumentColorsEvent(event.doc.id()));
|
||||
// Avoid re-requesting document colors if the change is a ghost transaction (completion)
|
||||
// because the language server will not know about the updates to the document and will
|
||||
// give out-of-date locations.
|
||||
if !event.ghost_transaction {
|
||||
// Cancel the ongoing request, if present.
|
||||
event.doc.color_swatch_controller.cancel();
|
||||
helix_event::send_blocking(&tx, DocumentColorsEvent(event.doc.id()));
|
||||
}
|
||||
|
||||
Ok(())
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue