From e6ab53619b329f0b68417cb9fab41086cd8f0174 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 28 Aug 2018 21:45:59 +0300 Subject: [PATCH] be more careful with adding semis --- crates/libeditor/src/typing.rs | 3 +++ crates/libsyntax2/src/yellow/syntax_text.rs | 6 ++++++ 2 files changed, 9 insertions(+) diff --git a/crates/libeditor/src/typing.rs b/crates/libeditor/src/typing.rs index 952caf7f61..65a8933a43 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 2685474701..d299fd700b 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) + } +}