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)
Unified · Split
| @@ -1921,20 +1921,20 @@ impl LocalLspStore { · 1920 unmodified lines | ||
| 1921 | 1921 | version: 0, |
| 1922 | 1922 | snapshot: initial_snapshot.clone(), |
| 1923 | 1923 | }; |
| 1924 | − let previous_snapshots = self | |
| 1925 | − .buffer_snapshots | |
| 1924 | + self.buffer_snapshots | |
| 1926 | 1925 | .entry(buffer_id) |
| 1927 | 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() { | |
| 1931 | − server.register_buffer( | |
| 1932 | − uri.clone(), | |
| 1933 | − adapter.language_id(&language.name()), | |
| 1934 | − 0, | |
| 1935 | − initial_snapshot.text(), | |
| 1936 | − ); | |
| 1937 | − } | |
| 1936 | + vec![snapshot] | |
| 1937 | + }); | |
| 1938 | 1938 | } |
| 1939 | 1939 | } |
| 1940 | 1940 | } |