From f3c7499be58941827ac8f500083b32ca74e0e8c4 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Sun, 21 Mar 2021 11:05:04 +0100 Subject: Add `'` to trigger_characters, allowing more direct lifetime completions --- crates/ide_completion/src/context.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ide_completion/src/context.rs') 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> { if kind == IDENT || kind == LIFETIME_IDENT || kind == UNDERSCORE || kind.is_keyword() { cov_mark::hit!(completes_if_prefix_is_keyword); self.original_token.text_range() + } else if kind == CHAR { + // assume we are completing a lifetime but the user has only typed the ' + cov_mark::hit!(completes_if_lifetime_without_idents); + TextRange::at(self.original_token.text_range().start(), TextSize::from(1)) } else { TextRange::empty(self.position.offset) } @@ -471,7 +475,7 @@ impl<'a> CompletionContext<'a> { self.lifetime_syntax = find_node_at_offset(original_file, lifetime.syntax().text_range().start()); if let Some(parent) = lifetime.syntax().parent() { - if parent.kind() == syntax::SyntaxKind::ERROR { + if parent.kind() == ERROR { return; } -- cgit v1.2.3