From 2b956fd3a83313cee37ff179eae843bc88dd572a Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 9 Oct 2018 16:00:20 +0300 Subject: Add on-enter handler Now, typing doc comments is much more pleasant --- crates/ra_analysis/src/lib.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/ra_analysis/src') diff --git a/crates/ra_analysis/src/lib.rs b/crates/ra_analysis/src/lib.rs index b4c7db476..f6ceb7eb2 100644 --- a/crates/ra_analysis/src/lib.rs +++ b/crates/ra_analysis/src/lib.rs @@ -184,6 +184,12 @@ impl Analysis { let file = self.imp.file_syntax(file_id); SourceChange::from_local_edit(file_id, "join lines", ra_editor::join_lines(&file, range)) } + pub fn on_enter(&self, file_id: FileId, offset: TextUnit) -> Option { + let file = self.imp.file_syntax(file_id); + let edit = ra_editor::on_enter(&file, offset)?; + let res = SourceChange::from_local_edit(file_id, "on enter", edit); + Some(res) + } pub fn on_eq_typed(&self, file_id: FileId, offset: TextUnit) -> Option { let file = self.imp.file_syntax(file_id); Some(SourceChange::from_local_edit(file_id, "add semicolon", ra_editor::on_eq_typed(&file, offset)?)) -- cgit v1.2.3