diff --git a/crates/editor/src/jsx_tag_auto_close.rs b/crates/editor/src/jsx_tag_auto_close.rs index 3efa3b8f4f..3a181f8e32 100644 --- a/crates/editor/src/jsx_tag_auto_close.rs +++ b/crates/editor/src/jsx_tag_auto_close.rs @@ -29,7 +29,7 @@ const ALREADY_CLOSED_PARENT_ELEMENT_WALK_BACK_LIMIT: usize = 2; pub(crate) fn should_auto_close( buffer: &BufferSnapshot, - edited_ranges: &[Range], + edited_ranges: &[Range], config: &JsxTagAutoCloseConfig, ) -> Option> { let mut to_auto_edit = vec![]; @@ -37,6 +37,7 @@ pub(crate) fn should_auto_close( let text = buffer .text_for_range(edited_range.clone()) .collect::(); + let edited_range = edited_range.to_offset(&buffer); if !text.ends_with(">") { continue; } @@ -94,7 +95,7 @@ pub(crate) fn should_auto_close( pub(crate) fn generate_auto_close_edits( buffer: &BufferSnapshot, - ranges: &[Range], + ranges: &[Range], config: &JsxTagAutoCloseConfig, state: Vec, ) -> Result, String)>> { @@ -381,7 +382,7 @@ pub(crate) fn handle_from( struct JsxAutoCloseEditContext { buffer: Entity, config: language::JsxTagAutoCloseConfig, - edits: Vec>, + edits: Vec>, } let mut edit_contexts = @@ -392,7 +393,10 @@ pub(crate) fn handle_from( continue; }; let snapshot = buffer.read(cx).snapshot(); - for edit in buffer.read(cx).edits_since(&buffer_version_initial) { + for (edit, range) in buffer + .read(cx) + .anchored_edits_since::(&buffer_version_initial) + { let Some(language) = snapshot.language_at(edit.new.end) else { continue; }; @@ -414,7 +418,7 @@ pub(crate) fn handle_from( edits: vec![], }) .edits - .push(edit.new); + .push(range); } } @@ -448,7 +452,6 @@ pub(crate) fn handle_from( }; let ensure_no_edits_since_start = || -> Option<()> { - //
wef,wefwef let has_edits_since_start = this .read_with(cx, |this, cx| { this.buffer.read_with(cx, |buffer, cx| {