aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_completion/src/context.rs
diff options
context:
space:
mode:
authorLukas Wirth <[email protected]>2021-03-21 10:05:04 +0000
committerLukas Wirth <[email protected]>2021-03-21 10:05:04 +0000
commitf3c7499be58941827ac8f500083b32ca74e0e8c4 (patch)
treee205e4608fe91eca4149c8a30cb6897489203243 /crates/ide_completion/src/context.rs
parent2280f62a40f31d83fd79b62c46dd3d610354d78c (diff)
Add `'` to trigger_characters, allowing more direct lifetime completions
Diffstat (limited to 'crates/ide_completion/src/context.rs')
-rw-r--r--crates/ide_completion/src/context.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/ide_completion/src/context.rs b/crates/ide_completion/src/context.rs
index 67e2d6f6c..32f81aec1 100644
--- a/crates/ide_completion/src/context.rs
+++ b/crates/ide_completion/src/context.rs
@@ -255,6 +255,10 @@ impl<'a> CompletionContext<'a> {
255 if kind == IDENT || kind == LIFETIME_IDENT || kind == UNDERSCORE || kind.is_keyword() { 255 if kind == IDENT || kind == LIFETIME_IDENT || kind == UNDERSCORE || kind.is_keyword() {
256 cov_mark::hit!(completes_if_prefix_is_keyword); 256 cov_mark::hit!(completes_if_prefix_is_keyword);
257 self.original_token.text_range() 257 self.original_token.text_range()
258 } else if kind == CHAR {
259 // assume we are completing a lifetime but the user has only typed the '
260 cov_mark::hit!(completes_if_lifetime_without_idents);
261 TextRange::at(self.original_token.text_range().start(), TextSize::from(1))
258 } else { 262 } else {
259 TextRange::empty(self.position.offset) 263 TextRange::empty(self.position.offset)
260 } 264 }
@@ -471,7 +475,7 @@ impl<'a> CompletionContext<'a> {
471 self.lifetime_syntax = 475 self.lifetime_syntax =
472 find_node_at_offset(original_file, lifetime.syntax().text_range().start()); 476 find_node_at_offset(original_file, lifetime.syntax().text_range().start());
473 if let Some(parent) = lifetime.syntax().parent() { 477 if let Some(parent) = lifetime.syntax().parent() {
474 if parent.kind() == syntax::SyntaxKind::ERROR { 478 if parent.kind() == ERROR {
475 return; 479 return;
476 } 480 }
477 481