diff --git a/crates/ra_ide/src/completion/complete_dot.rs b/crates/ra_ide/src/completion/complete_dot.rs index 22f5077f5b..82ec169135 100644 --- a/crates/ra_ide/src/completion/complete_dot.rs +++ b/crates/ra_ide/src/completion/complete_dot.rs @@ -720,7 +720,18 @@ mod tests { } ", ), - @r###"[]"### + @r###" + [ + CompletionItem { + label: "the_field", + source_range: [156; 156), + delete: [156; 156), + insert: "the_field", + kind: Field, + detail: "u32", + }, + ] + "### ); } diff --git a/crates/ra_ide/src/completion/completion_context.rs b/crates/ra_ide/src/completion/completion_context.rs index 3646fb8dcc..54589a2a83 100644 --- a/crates/ra_ide/src/completion/completion_context.rs +++ b/crates/ra_ide/src/completion/completion_context.rs @@ -135,7 +135,7 @@ impl<'a> CompletionContext<'a> { ), ) { let new_offset = hypothetical_expansion.1.text_range().start(); - if new_offset >= actual_expansion.text_range().end() { + if new_offset > actual_expansion.text_range().end() { break; } original_file = actual_expansion; diff --git a/crates/ra_mbe/src/mbe_expander.rs b/crates/ra_mbe/src/mbe_expander.rs index b2faa86d25..c2a5702f05 100644 --- a/crates/ra_mbe/src/mbe_expander.rs +++ b/crates/ra_mbe/src/mbe_expander.rs @@ -11,6 +11,7 @@ use rustc_hash::FxHashMap; use crate::{ExpandError, ExpandResult}; pub(crate) fn expand(rules: &crate::MacroRules, input: &tt::Subtree) -> ExpandResult { + eprintln!("expanding input: {:?}", input); let (mut result, mut unmatched_tokens, mut unmatched_patterns, mut err) = ( tt::Subtree::default(), usize::max_value(), @@ -39,9 +40,8 @@ fn expand_rule( rule: &crate::Rule, input: &tt::Subtree, ) -> ExpandResult<(tt::Subtree, usize, usize)> { - dbg!(&rule.lhs); - let (match_result, bindings_err) = dbg!(matcher::match_(&rule.lhs, input)); - let (res, transcribe_err) = dbg!(transcriber::transcribe(&rule.rhs, &match_result.bindings)); + let (match_result, bindings_err) = matcher::match_(&rule.lhs, input); + let (res, transcribe_err) = transcriber::transcribe(&rule.rhs, &match_result.bindings); ( (res, match_result.unmatched_tokens, match_result.unmatched_patterns), bindings_err.or(transcribe_err), diff --git a/crates/ra_mbe/src/syntax_bridge.rs b/crates/ra_mbe/src/syntax_bridge.rs index fcb73fbc7c..8aa3b906b6 100644 --- a/crates/ra_mbe/src/syntax_bridge.rs +++ b/crates/ra_mbe/src/syntax_bridge.rs @@ -73,6 +73,7 @@ pub fn token_tree_to_syntax_node( tt: &tt::Subtree, fragment_kind: FragmentKind, ) -> Result<(Parse, TokenMap), ExpandError> { + eprintln!("token_tree_to_syntax_node {:?} as {:?}", tt, fragment_kind); let tmp; let tokens = match tt { tt::Subtree { delimiter: None, token_trees } => token_trees.as_slice(), diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index b77b683b57..2fc6ce1e1a 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs @@ -565,10 +565,10 @@ fn meta_var_expr(p: &mut Parser) -> CompletedMarker { it } _ => { - while !p.at(R_DOLLAR) { + while !p.at(EOF) && !p.at(R_DOLLAR) { p.bump_any() } - p.bump(R_DOLLAR); + p.eat(R_DOLLAR); m.complete(p, ERROR) } }