Add support for the TextDocumentSyncKind LSP options
This commit is contained in:
parent
c379a6f2fb
commit
4887ea3563
1 changed files with 40 additions and 18 deletions
|
@ -2231,10 +2231,28 @@ impl Project {
|
|||
.get_mut(&buffer.remote_id())
|
||||
.and_then(|m| m.get_mut(&language_server.server_id()))?;
|
||||
let previous_snapshot = buffer_snapshots.last()?;
|
||||
let next_version = previous_snapshot.version + 1;
|
||||
|
||||
let content_changes = buffer
|
||||
.edits_since::<(PointUtf16, usize)>(previous_snapshot.snapshot.version())
|
||||
let document_sync_kind = language_server
|
||||
.capabilities()
|
||||
.text_document_sync
|
||||
.as_ref()
|
||||
.and_then(|sync| match sync {
|
||||
lsp::TextDocumentSyncCapability::Kind(kind) => Some(*kind),
|
||||
lsp::TextDocumentSyncCapability::Options(options) => options.change,
|
||||
});
|
||||
|
||||
let content_changes: Vec<_> = match document_sync_kind {
|
||||
Some(lsp::TextDocumentSyncKind::FULL) => {
|
||||
vec![lsp::TextDocumentContentChangeEvent {
|
||||
range: None,
|
||||
range_length: None,
|
||||
text: next_snapshot.text(),
|
||||
}]
|
||||
}
|
||||
Some(lsp::TextDocumentSyncKind::INCREMENTAL) => buffer
|
||||
.edits_since::<(PointUtf16, usize)>(
|
||||
previous_snapshot.snapshot.version(),
|
||||
)
|
||||
.map(|edit| {
|
||||
let edit_start = edit.new.start.0;
|
||||
let edit_end = edit_start + (edit.old.end.0 - edit.old.start.0);
|
||||
|
@ -2250,7 +2268,11 @@ impl Project {
|
|||
text: new_text,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
.collect(),
|
||||
_ => continue,
|
||||
};
|
||||
|
||||
let next_version = previous_snapshot.version + 1;
|
||||
|
||||
buffer_snapshots.push(LspBufferSnapshot {
|
||||
version: next_version,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue