aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/completion_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/completion_context.rs')
-rw-r--r--crates/ra_ide_api/src/completion/completion_context.rs8
1 files changed, 3 insertions, 5 deletions
diff --git a/crates/ra_ide_api/src/completion/completion_context.rs b/crates/ra_ide_api/src/completion/completion_context.rs
index b09c66c18..ca2069e2a 100644
--- a/crates/ra_ide_api/src/completion/completion_context.rs
+++ b/crates/ra_ide_api/src/completion/completion_context.rs
@@ -21,7 +21,7 @@ pub(crate) struct CompletionContext<'a> {
21 pub(super) function_syntax: Option<&'a ast::FnDef>, 21 pub(super) function_syntax: Option<&'a ast::FnDef>,
22 pub(super) use_item_syntax: Option<&'a ast::UseItem>, 22 pub(super) use_item_syntax: Option<&'a ast::UseItem>,
23 pub(super) is_param: bool, 23 pub(super) is_param: bool,
24 /// A single-indent path, like `foo`. 24 /// A single-indent path, like `foo`. `::foo` should not be considered a trivial path.
25 pub(super) is_trivial_path: bool, 25 pub(super) is_trivial_path: bool,
26 /// If not a trivial, path, the prefix (qualifier). 26 /// If not a trivial, path, the prefix (qualifier).
27 pub(super) path_prefix: Option<hir::Path>, 27 pub(super) path_prefix: Option<hir::Path>,
@@ -66,13 +66,11 @@ impl<'a> CompletionContext<'a> {
66 } 66 }
67 67
68 // The range of the identifier that is being completed. 68 // The range of the identifier that is being completed.
69 // This is purely advisory and can be used, for example, to highlight this range in the editor.
70 // Clients are expected to ignore this field.
71 pub(crate) fn source_range(&self) -> TextRange { 69 pub(crate) fn source_range(&self) -> TextRange {
72 match self.leaf.kind() { 70 match self.leaf.kind() {
73 // workaroud when completion is triggered by trigger characters. 71 // workaroud when completion is triggered by trigger characters.
74 DOT | COLONCOLON => TextRange::from_to(self.offset, self.offset), 72 IDENT => self.leaf.range(),
75 _ => self.leaf.range(), 73 _ => TextRange::offset_len(self.offset, 0.into()),
76 } 74 }
77 } 75 }
78 76