From ecc5a2e3df178194a25b85f90eb84e4386ed246d Mon Sep 17 00:00:00 2001 From: gfreezy <gfreezy@gmail.com> Date: Sun, 20 Jan 2019 13:34:16 +0800 Subject: [PATCH] workaround for trigger character --- crates/ra_ide_api/src/completion/completion_context.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs index fd4cfc94495..7bc2def1441 100644 --- a/crates/ra_ide_api/src/completion/completion_context.rs +++ b/crates/ra_ide_api/src/completion/completion_context.rs @@ -69,7 +69,11 @@ impl<'a> CompletionContext<'a> { // This is purely advisory and can be used, for example, to highlight this range in the editor. // Clients are expected to ignore this field. pub(crate) fn source_range(&self) -> TextRange { - self.leaf.range() + match self.leaf.kind() { + // workaroud when completion is triggered by trigger characters. + DOT | COLONCOLON => TextRange::from_to(self.offset, self.offset), + _ => self.leaf.range() + } } fn fill(&mut self, original_file: &'a SourceFile, offset: TextUnit) {