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.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs
index 37880448a..5f2797e41 100644
--- a/crates/ra_ide/src/completion/completion_context.rs
+++ b/crates/ra_ide/src/completion/completion_context.rs
@@ -7,7 +7,7 @@ use ra_syntax::{
7 algo::{find_covering_element, find_node_at_offset}, 7 algo::{find_covering_element, find_node_at_offset},
8 ast, AstNode, 8 ast, AstNode,
9 SyntaxKind::*, 9 SyntaxKind::*,
10 SyntaxNode, SyntaxToken, TextRange, TextUnit, 10 SyntaxNode, SyntaxToken, TextRange, TextSize,
11}; 11};
12use ra_text_edit::AtomTextEdit; 12use ra_text_edit::AtomTextEdit;
13 13
@@ -20,7 +20,7 @@ pub(crate) struct CompletionContext<'a> {
20 pub(super) sema: Semantics<'a, RootDatabase>, 20 pub(super) sema: Semantics<'a, RootDatabase>,
21 pub(super) db: &'a RootDatabase, 21 pub(super) db: &'a RootDatabase,
22 pub(super) config: &'a CompletionConfig, 22 pub(super) config: &'a CompletionConfig,
23 pub(super) offset: TextUnit, 23 pub(super) offset: TextSize,
24 /// The token before the cursor, in the original file. 24 /// The token before the cursor, in the original file.
25 pub(super) original_token: SyntaxToken, 25 pub(super) original_token: SyntaxToken,
26 /// The token before the cursor, in the macro-expanded file. 26 /// The token before the cursor, in the macro-expanded file.
@@ -167,7 +167,7 @@ impl<'a> CompletionContext<'a> {
167 match self.token.kind() { 167 match self.token.kind() {
168 // workaroud when completion is triggered by trigger characters. 168 // workaroud when completion is triggered by trigger characters.
169 IDENT => self.original_token.text_range(), 169 IDENT => self.original_token.text_range(),
170 _ => TextRange::offset_len(self.offset, 0.into()), 170 _ => TextRange::empty(self.offset),
171 } 171 }
172 } 172 }
173 173
@@ -190,7 +190,7 @@ impl<'a> CompletionContext<'a> {
190 &mut self, 190 &mut self,
191 original_file: &SyntaxNode, 191 original_file: &SyntaxNode,
192 file_with_fake_ident: SyntaxNode, 192 file_with_fake_ident: SyntaxNode,
193 offset: TextUnit, 193 offset: TextSize,
194 ) { 194 ) {
195 // First, let's try to complete a reference to some declaration. 195 // First, let's try to complete a reference to some declaration.
196 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(&file_with_fake_ident, offset) { 196 if let Some(name_ref) = find_node_at_offset::<ast::NameRef>(&file_with_fake_ident, offset) {
@@ -224,7 +224,8 @@ impl<'a> CompletionContext<'a> {
224 } 224 }
225 if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) { 225 if let Some(let_stmt) = bind_pat.syntax().ancestors().find_map(ast::LetStmt::cast) {
226 if let Some(pat) = let_stmt.pat() { 226 if let Some(pat) = let_stmt.pat() {
227 if bind_pat.syntax().text_range().is_subrange(&pat.syntax().text_range()) { 227 if pat.syntax().text_range().contains_range(bind_pat.syntax().text_range())
228 {
228 self.is_pat_binding_or_const = false; 229 self.is_pat_binding_or_const = false;
229 } 230 }
230 } 231 }
@@ -246,7 +247,7 @@ impl<'a> CompletionContext<'a> {
246 &mut self, 247 &mut self,
247 original_file: &SyntaxNode, 248 original_file: &SyntaxNode,
248 name_ref: ast::NameRef, 249 name_ref: ast::NameRef,
249 offset: TextUnit, 250 offset: TextSize,
250 ) { 251 ) {
251 self.name_ref_syntax = 252 self.name_ref_syntax =
252 find_node_at_offset(&original_file, name_ref.syntax().text_range().start()); 253 find_node_at_offset(&original_file, name_ref.syntax().text_range().start());