Don't insert an empty vector in Project::buffer_snapshots

Other code paths rely on at least a version always being there, so
we should enforce that invariant everywhere.
This commit is contained in:
Antonio Scandurra 2022-04-08 14:14:45 +02:00
parent 663beab1b9
commit c994263225

View File

@ -1216,7 +1216,7 @@ impl Project {
let file = File::from_dyn(buffer.file())?; let file = File::from_dyn(buffer.file())?;
let abs_path = file.as_local()?.abs_path(cx); let abs_path = file.as_local()?.abs_path(cx);
let uri = lsp::Url::from_file_path(abs_path).unwrap(); let uri = lsp::Url::from_file_path(abs_path).unwrap();
let buffer_snapshots = self.buffer_snapshots.entry(buffer.remote_id()).or_default(); let buffer_snapshots = self.buffer_snapshots.get_mut(&buffer.remote_id())?;
let (version, prev_snapshot) = buffer_snapshots.last()?; let (version, prev_snapshot) = buffer_snapshots.last()?;
let next_snapshot = buffer.text_snapshot(); let next_snapshot = buffer.text_snapshot();
let next_version = version + 1; let next_version = version + 1;