lsp: Track completion triggers for each language separately (#20471)
This PR improves how we handle completions in buffers with multiple LSPs. Context: while working on https://github.com/zed-industries/zed/issues/19777 with @mgsloan we noticed that completion triggers coming from language servers are not tracked properly. Namely, each buffer has `completion_triggers` field which is read from the configuration of a language server. The problem is, there can be multiple language servers for a single buffer, in which case we'd just stick to the one that was registered last. This PR makes the tracking a bit more fine-grained. We now track not only what the completion triggers are, but also their origin server id. Whenever completion triggers are updated, we recreate the completion triggers set. Release Notes: - Fixed completions not triggering when multiple language servers are used for a single file.
This commit is contained in:
parent
2b7ee1e872
commit
f3320998a8
7 changed files with 91 additions and 24 deletions
|
@ -79,11 +79,13 @@ pub fn serialize_operation(operation: &crate::Operation) -> proto::Operation {
|
|||
crate::Operation::UpdateCompletionTriggers {
|
||||
triggers,
|
||||
lamport_timestamp,
|
||||
server_id,
|
||||
} => proto::operation::Variant::UpdateCompletionTriggers(
|
||||
proto::operation::UpdateCompletionTriggers {
|
||||
replica_id: lamport_timestamp.replica_id as u32,
|
||||
lamport_timestamp: lamport_timestamp.value,
|
||||
triggers: triggers.clone(),
|
||||
triggers: triggers.iter().cloned().collect(),
|
||||
language_server_id: server_id.to_proto(),
|
||||
},
|
||||
),
|
||||
}),
|
||||
|
@ -326,6 +328,7 @@ pub fn deserialize_operation(message: proto::Operation) -> Result<crate::Operati
|
|||
replica_id: message.replica_id as ReplicaId,
|
||||
value: message.lamport_timestamp,
|
||||
},
|
||||
server_id: LanguageServerId::from_proto(message.language_server_id),
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue