lsp store: Refactor to use shared method to find buffer snapshot (#17929)
Came across this code while investigating something else and I think we should use the same method. As far as I know, it does the same thing, except that `buffer_snapshot_for_lsp_version` also cleans up the stored snapshots. Release Notes: - N/A
This commit is contained in:
parent
5f0925fb5d
commit
c34fc5c6e5
1 changed files with 9 additions and 14 deletions
|
@ -6383,21 +6383,16 @@ impl LspStore {
|
||||||
let buffer_id = buffer_to_edit.read(cx).remote_id();
|
let buffer_id = buffer_to_edit.read(cx).remote_id();
|
||||||
let version = if let Some(buffer_version) = op.text_document.version
|
let version = if let Some(buffer_version) = op.text_document.version
|
||||||
{
|
{
|
||||||
this.buffer_snapshots
|
this.buffer_snapshot_for_lsp_version(
|
||||||
.get(&buffer_id)
|
&buffer_to_edit,
|
||||||
.and_then(|server_to_snapshots| {
|
language_server.server_id(),
|
||||||
let all_snapshots = server_to_snapshots
|
Some(buffer_version),
|
||||||
.get(&language_server.server_id())?;
|
cx,
|
||||||
all_snapshots
|
)
|
||||||
.binary_search_by_key(&buffer_version, |snapshot| {
|
.ok()
|
||||||
snapshot.version
|
.map(|snapshot| snapshot.version)
|
||||||
})
|
|
||||||
.ok()
|
|
||||||
.and_then(|index| all_snapshots.get(index))
|
|
||||||
})
|
|
||||||
.map(|lsp_snapshot| lsp_snapshot.snapshot.version())
|
|
||||||
} else {
|
} else {
|
||||||
Some(buffer_to_edit.read(cx).saved_version())
|
Some(buffer_to_edit.read(cx).saved_version().clone())
|
||||||
};
|
};
|
||||||
|
|
||||||
let most_recent_edit = version.and_then(|version| {
|
let most_recent_edit = version.and_then(|version| {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue