mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-08-03 01:42:14 +00:00
fix: bad early return in param_completions (#350)
* fix: bad early return in param_completions * dev: update snapshot * dev: filter result
This commit is contained in:
parent
0a1c625397
commit
6967dc5a22
3 changed files with 78 additions and 16 deletions
|
@ -0,0 +1,3 @@
|
||||||
|
// contains: font
|
||||||
|
|
||||||
|
#set text(fo /* range -2..0 */)
|
|
@ -0,0 +1,54 @@
|
||||||
|
---
|
||||||
|
source: crates/tinymist-query/src/completion.rs
|
||||||
|
description: Completion on o (30..32)
|
||||||
|
expression: "JsonRepr::new_pure(results)"
|
||||||
|
input_file: crates/tinymist-query/src/fixtures/completion/half_completion.typ
|
||||||
|
---
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"isIncomplete": false,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": 5,
|
||||||
|
"label": "font",
|
||||||
|
"sortText": "013",
|
||||||
|
"textEdit": {
|
||||||
|
"newText": "font: ${1:}, ",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 11,
|
||||||
|
"line": 2
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 10,
|
||||||
|
"line": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"isIncomplete": false,
|
||||||
|
"items": [
|
||||||
|
{
|
||||||
|
"kind": 5,
|
||||||
|
"label": "font",
|
||||||
|
"sortText": "013",
|
||||||
|
"textEdit": {
|
||||||
|
"newText": "font: ${1:}",
|
||||||
|
"range": {
|
||||||
|
"end": {
|
||||||
|
"character": 12,
|
||||||
|
"line": 2
|
||||||
|
},
|
||||||
|
"start": {
|
||||||
|
"character": 10,
|
||||||
|
"line": 2
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
|
@ -585,7 +585,7 @@ pub fn param_completions<'a>(
|
||||||
let signature = analyze_dyn_signature(ctx.ctx, func.clone());
|
let signature = analyze_dyn_signature(ctx.ctx, func.clone());
|
||||||
|
|
||||||
let leaf_type = ctx.ctx.literal_type_of_node(ctx.leaf.clone());
|
let leaf_type = ctx.ctx.literal_type_of_node(ctx.leaf.clone());
|
||||||
log::info!("pos_param_completion_by_type: {:?}", leaf_type);
|
log::debug!("pos_param_completion_by_type: {:?}", leaf_type);
|
||||||
|
|
||||||
for arg in args.items() {
|
for arg in args.items() {
|
||||||
if let ast::Arg::Named(named) = arg {
|
if let ast::Arg::Named(named) = arg {
|
||||||
|
@ -595,34 +595,39 @@ pub fn param_completions<'a>(
|
||||||
|
|
||||||
let primary_sig = signature.primary();
|
let primary_sig = signature.primary();
|
||||||
|
|
||||||
log::debug!("pos_param_completion: {:?}", pos_index);
|
'pos_check: {
|
||||||
|
let mut doc = None;
|
||||||
|
|
||||||
let mut doc = None;
|
if let Some(pos_index) = pos_index {
|
||||||
if let Some(pos_index) = pos_index {
|
let pos = primary_sig.pos.get(pos_index);
|
||||||
let pos = primary_sig.pos.get(pos_index);
|
log::debug!("pos_param_completion_to: {:?}", pos);
|
||||||
log::debug!("pos_param_completion_to: {:?}", pos);
|
|
||||||
|
|
||||||
if let Some(pos) = pos {
|
if let Some(pos) = pos {
|
||||||
if set && !pos.settable {
|
if set && !pos.settable {
|
||||||
return;
|
break 'pos_check;
|
||||||
}
|
}
|
||||||
|
|
||||||
doc = Some(plain_docs_sentence(&pos.docs));
|
doc = Some(plain_docs_sentence(&pos.docs));
|
||||||
|
|
||||||
if pos.positional {
|
if pos.positional {
|
||||||
type_completion(ctx, &pos.base_type, doc.as_deref());
|
type_completion(ctx, &pos.base_type, doc.as_deref());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if let Some(leaf_type) = leaf_type {
|
if let Some(leaf_type) = leaf_type {
|
||||||
type_completion(ctx, &leaf_type, doc.as_deref());
|
type_completion(ctx, &leaf_type, doc.as_deref());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (name, param) in &primary_sig.named {
|
for (name, param) in &primary_sig.named {
|
||||||
if ctx.seen_field(name.as_ref().into()) {
|
if ctx.seen_field(name.as_ref().into()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
log::debug!(
|
||||||
|
"pos_named_param_completion_to({set:?}): {name:?} {:?}",
|
||||||
|
param.settable
|
||||||
|
);
|
||||||
|
|
||||||
if set && !param.settable {
|
if set && !param.settable {
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue