Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

editor: Fix extra characters were being written at the end of an HTML tag (#28529)

Smit Barmase64241f7d2f70
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index 936170349ab..51435aefe39 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -3130,6 +3130,7 @@ impl Editor {
let mut new_selections = Vec::with_capacity(selections.len());
let mut new_autoclose_regions = Vec::new();
let snapshot = self.buffer.read(cx).read(cx);
+ let mut clear_linked_edit_ranges = false;
for (selection, autoclose_region) in
self.selections_with_autoclose_regions(selections, &snapshot)
@@ -3357,6 +3358,8 @@ impl Editor {
.extend(edits.into_iter().map(|range| (range, text.clone())));
}
}
+ } else {
+ clear_linked_edit_ranges = true;
}
}
@@ -3367,6 +3370,9 @@ impl Editor {
drop(snapshot);
self.transact(window, cx, |this, window, cx| {
+ if clear_linked_edit_ranges {
+ this.linked_edit_ranges.clear();
+ }
let initial_buffer_versions =
jsx_tag_auto_close::construct_initial_buffer_versions_map(this, &edits, cx);
diff --git a/crates/editor/src/linked_editing_ranges.rs b/crates/editor/src/linked_editing_ranges.rs
index 90617d52f24..7c2672fc0da 100644
--- a/crates/editor/src/linked_editing_ranges.rs
+++ b/crates/editor/src/linked_editing_ranges.rs
@@ -34,6 +34,10 @@ impl LinkedEditingRanges {
pub(super) fn is_empty(&self) -> bool {
self.0.is_empty()
}
+
+ pub(super) fn clear(&mut self) {
+ self.0.clear();
+ }
}
const UPDATE_DEBOUNCE: Duration = Duration::from_millis(50);