diff --git a/crates/libeditor/src/typing.rs b/crates/libeditor/src/typing.rs index 952caf7f612..65a8933a43a 100644 --- a/crates/libeditor/src/typing.rs +++ b/crates/libeditor/src/typing.rs @@ -65,6 +65,9 @@ pub fn on_eq_typed(file: &File, offset: TextUnit) -> Option { if contains_offset_nonstrict(expr_range, offset) && offset != expr_range.start() { return None; } + if file.syntax().text().slice(offset..expr_range.start()).contains('\n') { + return None; + } } else { return None; } diff --git a/crates/libsyntax2/src/yellow/syntax_text.rs b/crates/libsyntax2/src/yellow/syntax_text.rs index 26854747019..d299fd700bf 100644 --- a/crates/libsyntax2/src/yellow/syntax_text.rs +++ b/crates/libsyntax2/src/yellow/syntax_text.rs @@ -99,3 +99,9 @@ impl SyntaxTextSlice for ops::RangeFrom { Some(TextRange::from_to(self.start, range.end())) } } + +impl SyntaxTextSlice for ops::Range { + fn restrict(&self, range: TextRange) -> Option { + TextRange::from_to(self.start, self.end).restrict(range) + } +}