aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src')
-rw-r--r--crates/ra_ide/src/diagnostics.rs2
-rw-r--r--crates/ra_ide/src/lib.rs1
-rw-r--r--crates/ra_ide/src/references/rename.rs3
-rw-r--r--crates/ra_ide/src/typing/on_enter.rs29
4 files changed, 13 insertions, 22 deletions
diff --git a/crates/ra_ide/src/diagnostics.rs b/crates/ra_ide/src/diagnostics.rs
index 54c2bcc09..c2819bbf7 100644
--- a/crates/ra_ide/src/diagnostics.rs
+++ b/crates/ra_ide/src/diagnostics.rs
@@ -628,7 +628,6 @@ mod tests {
628 path: "foo.rs", 628 path: "foo.rs",
629 }, 629 },
630 ], 630 ],
631 cursor_position: None,
632 is_snippet: false, 631 is_snippet: false,
633 }, 632 },
634 ), 633 ),
@@ -685,7 +684,6 @@ mod tests {
685 }, 684 },
686 ], 685 ],
687 file_system_edits: [], 686 file_system_edits: [],
688 cursor_position: None,
689 is_snippet: false, 687 is_snippet: false,
690 }, 688 },
691 ), 689 ),
diff --git a/crates/ra_ide/src/lib.rs b/crates/ra_ide/src/lib.rs
index 83cb498f7..1d7bacbf6 100644
--- a/crates/ra_ide/src/lib.rs
+++ b/crates/ra_ide/src/lib.rs
@@ -87,7 +87,6 @@ pub use ra_db::{
87pub use ra_ide_db::{ 87pub use ra_ide_db::{
88 change::{AnalysisChange, LibraryData}, 88 change::{AnalysisChange, LibraryData},
89 line_index::{LineCol, LineIndex}, 89 line_index::{LineCol, LineIndex},
90 line_index_utils::translate_offset_with_edit,
91 search::SearchScope, 90 search::SearchScope,
92 source_change::{FileSystemEdit, SourceChange, SourceFileEdit}, 91 source_change::{FileSystemEdit, SourceChange, SourceFileEdit},
93 symbol_index::Query, 92 symbol_index::Query,
diff --git a/crates/ra_ide/src/references/rename.rs b/crates/ra_ide/src/references/rename.rs
index 62ec8d85d..55c3319cb 100644
--- a/crates/ra_ide/src/references/rename.rs
+++ b/crates/ra_ide/src/references/rename.rs
@@ -669,7 +669,6 @@ mod tests {
669 dst_path: "bar/foo2.rs", 669 dst_path: "bar/foo2.rs",
670 }, 670 },
671 ], 671 ],
672 cursor_position: None,
673 is_snippet: false, 672 is_snippet: false,
674 }, 673 },
675 }, 674 },
@@ -722,7 +721,6 @@ mod tests {
722 dst_path: "foo2/mod.rs", 721 dst_path: "foo2/mod.rs",
723 }, 722 },
724 ], 723 ],
725 cursor_position: None,
726 is_snippet: false, 724 is_snippet: false,
727 }, 725 },
728 }, 726 },
@@ -819,7 +817,6 @@ mod tests {
819 dst_path: "bar/foo2.rs", 817 dst_path: "bar/foo2.rs",
820 }, 818 },
821 ], 819 ],
822 cursor_position: None,
823 is_snippet: false, 820 is_snippet: false,
824 }, 821 },
825 }, 822 },
diff --git a/crates/ra_ide/src/typing/on_enter.rs b/crates/ra_ide/src/typing/on_enter.rs
index 78a40cc94..85be14ad3 100644
--- a/crates/ra_ide/src/typing/on_enter.rs
+++ b/crates/ra_ide/src/typing/on_enter.rs
@@ -38,17 +38,15 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour
38 } 38 }
39 39
40 let indent = node_indent(&file, comment.syntax())?; 40 let indent = node_indent(&file, comment.syntax())?;
41 let inserted = format!("\n{}{} ", indent, prefix); 41 let inserted = format!("\n{}{} $0", indent, prefix);
42 let cursor_position = position.offset + TextSize::of(&inserted);
43 let edit = TextEdit::insert(position.offset, inserted); 42 let edit = TextEdit::insert(position.offset, inserted);
44 43
45 Some( 44 let mut res = SourceChange::source_file_edit(
46 SourceChange::source_file_edit( 45 "On enter",
47 "On enter", 46 SourceFileEdit { edit, file_id: position.file_id },
48 SourceFileEdit { edit, file_id: position.file_id }, 47 );
49 ) 48 res.is_snippet = true;
50 .with_cursor(FilePosition { offset: cursor_position, file_id: position.file_id }), 49 Some(res)
51 )
52} 50}
53 51
54fn followed_by_comment(comment: &ast::Comment) -> bool { 52fn followed_by_comment(comment: &ast::Comment) -> bool {
@@ -84,7 +82,7 @@ fn node_indent(file: &SourceFile, token: &SyntaxToken) -> Option<SmolStr> {
84 82
85#[cfg(test)] 83#[cfg(test)]
86mod tests { 84mod tests {
87 use test_utils::{add_cursor, assert_eq_text, extract_offset}; 85 use test_utils::{assert_eq_text, extract_offset};
88 86
89 use crate::mock_analysis::single_file; 87 use crate::mock_analysis::single_file;
90 88
@@ -98,7 +96,6 @@ mod tests {
98 assert_eq!(result.source_file_edits.len(), 1); 96 assert_eq!(result.source_file_edits.len(), 1);
99 let mut actual = before.to_string(); 97 let mut actual = before.to_string();
100 result.source_file_edits[0].edit.apply(&mut actual); 98 result.source_file_edits[0].edit.apply(&mut actual);
101 let actual = add_cursor(&actual, result.cursor_position.unwrap().offset);
102 Some(actual) 99 Some(actual)
103 } 100 }
104 101
@@ -121,7 +118,7 @@ fn foo() {
121", 118",
122 r" 119 r"
123/// Some docs 120/// Some docs
124/// <|> 121/// $0
125fn foo() { 122fn foo() {
126} 123}
127", 124",
@@ -137,7 +134,7 @@ impl S {
137 r" 134 r"
138impl S { 135impl S {
139 /// Some 136 /// Some
140 /// <|> docs. 137 /// $0 docs.
141 fn foo() {} 138 fn foo() {}
142} 139}
143", 140",
@@ -151,7 +148,7 @@ fn foo() {
151", 148",
152 r" 149 r"
153/// 150///
154/// <|> Some docs 151/// $0 Some docs
155fn foo() { 152fn foo() {
156} 153}
157", 154",
@@ -175,7 +172,7 @@ fn main() {
175 r" 172 r"
176fn main() { 173fn main() {
177 // Fix 174 // Fix
178 // <|> me 175 // $0 me
179 let x = 1 + 1; 176 let x = 1 + 1;
180} 177}
181", 178",
@@ -195,7 +192,7 @@ fn main() {
195 r" 192 r"
196fn main() { 193fn main() {
197 // Fix 194 // Fix
198 // <|> 195 // $0
199 // me 196 // me
200 let x = 1 + 1; 197 let x = 1 + 1;
201} 198}