edit prediction: Try to fix panic in Buffer::preview_edits
(#24654)
We've seen a few crashes in `SyntaxSnapshot::reparse_with_ranges` during `Buffer::preview_edits`, where an offset conversion fails because it is out of range. We are not sure how exactly this is happening. Our theory is that the syntax snapshot is using an outdated state when edits happen in the meantime (while interpolating). This is an attempt to see if it helps with the panics, hopefully we can revisit this when we have a better understanding of the issue. Co-Authored-by: Antonio <antonio@zed.dev> Release Notes: - N/A Co-authored-by: Antonio <antonio@zed.dev>
This commit is contained in:
parent
7b45901d96
commit
8fa85c41a1
1 changed files with 4 additions and 0 deletions
|
@ -1102,6 +1102,10 @@ impl Buffer {
|
||||||
let mut syntax_snapshot = self.syntax_map.lock().snapshot();
|
let mut syntax_snapshot = self.syntax_map.lock().snapshot();
|
||||||
cx.background_executor().spawn(async move {
|
cx.background_executor().spawn(async move {
|
||||||
if !edits.is_empty() {
|
if !edits.is_empty() {
|
||||||
|
if let Some(language) = language.clone() {
|
||||||
|
syntax_snapshot.reparse(&old_snapshot, registry.clone(), language);
|
||||||
|
}
|
||||||
|
|
||||||
branch_buffer.edit(edits.iter().cloned());
|
branch_buffer.edit(edits.iter().cloned());
|
||||||
let snapshot = branch_buffer.snapshot();
|
let snapshot = branch_buffer.snapshot();
|
||||||
syntax_snapshot.interpolate(&snapshot);
|
syntax_snapshot.interpolate(&snapshot);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue