mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-24 13:13:43 +00:00
feat: allow fuzzy selection to deref targets (#46)
This commit is contained in:
parent
be244840b2
commit
f683426753
1 changed files with 43 additions and 0 deletions
|
@ -28,8 +28,51 @@ impl<'a> DerefTarget<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
fn is_mark(sk: SyntaxKind) -> bool {
|
||||
use SyntaxKind::*;
|
||||
matches!(
|
||||
sk,
|
||||
MathAlignPoint
|
||||
| Plus
|
||||
| Minus
|
||||
| Slash
|
||||
| Hat
|
||||
| Dot
|
||||
| Eq
|
||||
| EqEq
|
||||
| ExclEq
|
||||
| Lt
|
||||
| LtEq
|
||||
| Gt
|
||||
| GtEq
|
||||
| PlusEq
|
||||
| HyphEq
|
||||
| StarEq
|
||||
| SlashEq
|
||||
| Dots
|
||||
| Arrow
|
||||
| Not
|
||||
| And
|
||||
| Or
|
||||
| LeftBrace
|
||||
| RightBrace
|
||||
| LeftBracket
|
||||
| RightBracket
|
||||
| LeftParen
|
||||
| RightParen
|
||||
| Comma
|
||||
| Semicolon
|
||||
| Colon
|
||||
| Hash
|
||||
)
|
||||
}
|
||||
|
||||
pub fn get_deref_target(node: LinkedNode) -> Option<DerefTarget> {
|
||||
let mut ancestor = node;
|
||||
if ancestor.kind().is_trivia() || is_mark(ancestor.kind()) {
|
||||
ancestor = ancestor.prev_sibling()?;
|
||||
}
|
||||
|
||||
while !ancestor.is::<ast::Expr>() {
|
||||
ancestor = ancestor.parent()?.clone();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue