fix: skip code completion when editing length (#882)

This commit is contained in:
Myriad-Dreamin 2024-11-22 16:15:40 +08:00 committed by GitHub
parent 49d33e5047
commit 422971c8b6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 33 additions and 0 deletions

View file

@ -101,6 +101,27 @@ impl StatefulRequest for CompletionRequest {
}
}
// Skip if an error node starts with number (e.g. `1pt`)
if matches!(
deref_target,
Some(DerefTarget::Callee(..) | DerefTarget::VarAccess(..) | DerefTarget::Normal(..),)
) {
let node = LinkedNode::new(source.root()).leaf_at_compat(cursor)?;
if node.erroneous() {
let mut n = node.text().chars();
match n.next() {
Some(c) if c.is_numeric() => return None,
Some('.') => {
if matches!(n.next(), Some(c) if c.is_numeric()) {
return None;
}
}
_ => {}
}
}
}
// Do some completion specific to the deref target
let mut ident_like = None;
let mut completion_result = None;