aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion/completion_context.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/completion/completion_context.rs')
-rw-r--r--crates/ra_ide/src/completion/completion_context.rs19
1 files changed, 5 insertions, 14 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index ef22ea54d..7688a1483 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -196,20 +196,11 @@ impl<'a> CompletionContext<'a> {
196 // The range of the identifier that is being completed. 196 // The range of the identifier that is being completed.
197 pub(crate) fn source_range(&self) -> TextRange { 197 pub(crate) fn source_range(&self) -> TextRange {
198 // check kind of macro-expanded token, but use range of original token 198 // check kind of macro-expanded token, but use range of original token
199 match self.token.kind() { 199 if self.token.kind() == IDENT || self.token.kind().is_keyword() {
200 // workaroud when completion is triggered by trigger characters. 200 mark::hit!(completes_if_prefix_is_keyword);
201 IDENT => self.original_token.text_range(), 201 self.original_token.text_range()
202 _ => { 202 } else {
203 // If we haven't characters between keyword and our cursor we take the keyword start range to edit 203 TextRange::empty(self.offset)
204 if self.token.kind().is_keyword()
205 && self.offset == self.original_token.text_range().end()
206 {
207 mark::hit!(completes_bindings_from_for_with_in_prefix);
208 TextRange::empty(self.original_token.text_range().start())
209 } else {
210 TextRange::empty(self.offset)
211 }
212 }
213 } 204 }
214 } 205 }
215 206