aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-20 19:28:40 +0000
committerAleksey Kladov <[email protected]>2019-11-22 07:38:33 +0000
commit58413b22d7b5a6f416580dd07831f94f22857de2 (patch)
tree3a59052e06d9f3483d3dd807e95dd8ae3ee675f7 /crates/ra_ide_api/src
parentc9273828b3c44fba62d1b989480c287d923839d2 (diff)
Don't continue line comments
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/typing.rs34
1 files changed, 31 insertions, 3 deletions
diff --git a/crates/ra_ide_api/src/typing.rs b/crates/ra_ide_api/src/typing.rs
index d51132f73..21e5be9b3 100644
--- a/crates/ra_ide_api/src/typing.rs
+++ b/crates/ra_ide_api/src/typing.rs
@@ -40,9 +40,13 @@ pub(crate) fn on_enter(db: &RootDatabase, position: FilePosition) -> Option<Sour
40 } 40 }
41 41
42 let prefix = comment.prefix(); 42 let prefix = comment.prefix();
43 if position.offset 43 let comment_range = comment.syntax().text_range();
44 < comment.syntax().text_range().start() + TextUnit::of_str(prefix) + TextUnit::from(1) 44 if position.offset < comment_range.start() + TextUnit::of_str(prefix) + TextUnit::from(1) {
45 { 45 return None;
46 }
47
48 // Continuing non-doc line comments (like this one :) ) is annoying
49 if prefix == "//" && comment_range.end() == position.offset {
46 return None; 50 return None;
47 } 51 }
48 52
@@ -247,6 +251,30 @@ impl S {
247} 251}
248", 252",
249 ); 253 );
254 do_check(
255 r"
256fn main() {
257 // Fix<|> me
258 let x = 1 + 1;
259}
260",
261 r"
262fn main() {
263 // Fix
264 // <|> me
265 let x = 1 + 1;
266}
267",
268 );
269 do_check_noop(
270 r"
271fn main() {
272 // Fix me<|>
273 let x = 1 + 1;
274}
275",
276 );
277
250 do_check_noop(r"<|>//! docz"); 278 do_check_noop(r"<|>//! docz");
251 } 279 }
252 280