History

lsp: Fix buffer snapshots sometimes going missing (#25548)

A call to register_buffer_with_language_servers could nuke existing snapshots, even when the buffer was already registered with a server. Essentially, had we had the else branch in place, this would have been detected. Closes #ISSUE Release Notes: - Fixed Rust analyzer renames sometimes failing. (Preview only)

Piotr Osiewicz committed 1 year ago

Commit 86283f41 parent 8e1003e1 file · +11 −11Browse files

Unified · Split

crates/project/src/lsp_store.rs+11−11
@@ -1921,20 +1921,20 @@ impl LocalLspStore { · 1920 unmodified lines
1921 version: 0,1921 version: 0,
1922 snapshot: initial_snapshot.clone(),1922 snapshot: initial_snapshot.clone(),
1923 };1923 };
1924 let previous_snapshots = self1924 self.buffer_snapshots
1925 .buffer_snapshots
1926 .entry(buffer_id)1925 .entry(buffer_id)
1927 .or_default()1926 .or_default()
1928 .insert(server.server_id(), vec![snapshot]);1927 .entry(server.server_id())
1928 .or_insert_with(|| {
1929 server.register_buffer(
1930 uri.clone(),
1931 adapter.language_id(&language.name()),
1932 0,
1933 initial_snapshot.text(),
1934 );
1929 1935
1930 if previous_snapshots.is_none() {1936 vec![snapshot]
1931 server.register_buffer(1937 });
1932 uri.clone(),
1933 adapter.language_id(&language.name()),
1934 0,
1935 initial_snapshot.text(),
1936 );
1937 }
1938 }1938 }
1939 }1939 }
1940 }1940 }

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t