mirror of
https://github.com/zed-industries/zed.git
synced 2025-02-02 08:20:09 +00:00
lsp store: Refactor to use shared method to find buffer snapshot (#17929)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
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 version = if let Some(buffer_version) = op.text_document.version
|
||||
{
|
||||
this.buffer_snapshots
|
||||
.get(&buffer_id)
|
||||
.and_then(|server_to_snapshots| {
|
||||
let all_snapshots = server_to_snapshots
|
||||
.get(&language_server.server_id())?;
|
||||
all_snapshots
|
||||
.binary_search_by_key(&buffer_version, |snapshot| {
|
||||
snapshot.version
|
||||
})
|
||||
.ok()
|
||||
.and_then(|index| all_snapshots.get(index))
|
||||
})
|
||||
.map(|lsp_snapshot| lsp_snapshot.snapshot.version())
|
||||
this.buffer_snapshot_for_lsp_version(
|
||||
&buffer_to_edit,
|
||||
language_server.server_id(),
|
||||
Some(buffer_version),
|
||||
cx,
|
||||
)
|
||||
.ok()
|
||||
.map(|snapshot| snapshot.version)
|
||||
} 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| {
|
||||
|
|
Loading…
Reference in a new issue