mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-24 05:05:00 +00:00
feat: match named arg parent in literals (#1418)
This commit is contained in:
parent
ebfc93c104
commit
96cdab38f6
3 changed files with 71 additions and 0 deletions
|
@ -1240,6 +1240,20 @@ fn arg_context<'a>(
|
|||
Some(ArgClass::Named(args_node.find(param_ident.span())?))
|
||||
}
|
||||
_ => {
|
||||
let parent = node.parent();
|
||||
if let Some(parent) = parent {
|
||||
if parent.kind() == SyntaxKind::Named {
|
||||
let param_ident = parent.cast::<ast::Named>()?;
|
||||
let name = param_ident.name();
|
||||
let init = param_ident.expr();
|
||||
let init = parent.find(init.span())?;
|
||||
if init.range().contains(&node.offset()) {
|
||||
let name = args_node.find(name.span())?;
|
||||
return Some(ArgClass::Named(name));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut spreads = EcoVec::new();
|
||||
let mut positional = 0;
|
||||
let is_spread = node.kind() == SyntaxKind::Spread;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
/// contains: "New Computer Modern"
|
||||
|
||||
#set text(font: (name: "" /* range -2..0 */))
|
|
@ -0,0 +1,54 @@
|
|||
---
|
||||
source: crates/tinymist-query/src/completion.rs
|
||||
description: "Completion on \" (63..65)"
|
||||
expression: "JsonRepr::new_pure(results)"
|
||||
input_file: crates/tinymist-query/src/fixtures/completion/modify_string_3.typ
|
||||
---
|
||||
[
|
||||
{
|
||||
"isIncomplete": false,
|
||||
"items": [
|
||||
{
|
||||
"kind": 6,
|
||||
"label": "\"New Computer Modern\"",
|
||||
"sortText": "003",
|
||||
"textEdit": {
|
||||
"newText": "New Computer Modern",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 24,
|
||||
"line": 2
|
||||
},
|
||||
"start": {
|
||||
"character": 24,
|
||||
"line": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"isIncomplete": false,
|
||||
"items": [
|
||||
{
|
||||
"kind": 6,
|
||||
"label": "\"New Computer Modern\"",
|
||||
"sortText": "003",
|
||||
"textEdit": {
|
||||
"newText": "New Computer Modern\"",
|
||||
"range": {
|
||||
"end": {
|
||||
"character": 25,
|
||||
"line": 2
|
||||
},
|
||||
"start": {
|
||||
"character": 25,
|
||||
"line": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
Loading…
Add table
Add a link
Reference in a new issue