Fix LSP rename in Go (#25073)
Some language servers report version 0 even if the buffer hasn't been opened yet. We detect this case and treat it as if the version was `None`. Closes #23706 Release Notes: - Fixed a bug that prevented renames for some languages.
This commit is contained in:
parent
b4fc127e49
commit
00bb9a4e92
1 changed files with 12 additions and 4 deletions
|
@ -1986,13 +1986,21 @@ impl LocalLspStore {
|
||||||
|
|
||||||
if let Some(version) = version {
|
if let Some(version) = version {
|
||||||
let buffer_id = buffer.read(cx).remote_id();
|
let buffer_id = buffer.read(cx).remote_id();
|
||||||
let snapshots = self
|
let snapshots = if let Some(snapshots) = self
|
||||||
.buffer_snapshots
|
.buffer_snapshots
|
||||||
.get_mut(&buffer_id)
|
.get_mut(&buffer_id)
|
||||||
.and_then(|m| m.get_mut(&server_id))
|
.and_then(|m| m.get_mut(&server_id))
|
||||||
.ok_or_else(|| {
|
{
|
||||||
anyhow!("no snapshots found for buffer {buffer_id} and server {server_id}")
|
snapshots
|
||||||
})?;
|
} else if version == 0 {
|
||||||
|
// Some language servers report version 0 even if the buffer hasn't been opened yet.
|
||||||
|
// We detect this case and treat it as if the version was `None`.
|
||||||
|
return Ok(buffer.read(cx).text_snapshot());
|
||||||
|
} else {
|
||||||
|
return Err(anyhow!(
|
||||||
|
"no snapshots found for buffer {buffer_id} and server {server_id}"
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
let found_snapshot = snapshots
|
let found_snapshot = snapshots
|
||||||
.binary_search_by_key(&version, |e| e.version)
|
.binary_search_by_key(&version, |e| e.version)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue