mirror of
https://github.com/Myriad-Dreamin/tinymist.git
synced 2025-07-24 05:05:00 +00:00
feat: complete both open and closed labels (#302)
* feat: complete both open and closed labels * QAQ
This commit is contained in:
parent
071d9072e1
commit
8f5725f51a
3 changed files with 10 additions and 7 deletions
|
@ -40,10 +40,10 @@ pub fn autocomplete(
|
|||
mut ctx: CompletionContext,
|
||||
) -> Option<(usize, bool, Vec<Completion>, Vec<lsp_types::CompletionItem>)> {
|
||||
let _ = complete_comments(&mut ctx)
|
||||
|| complete_labels(&mut ctx)
|
||||
|| complete_type(&mut ctx).is_none() && {
|
||||
log::info!("continue after completing type");
|
||||
complete_field_accesses(&mut ctx)
|
||||
|| complete_open_labels(&mut ctx)
|
||||
|| complete_imports(&mut ctx)
|
||||
|| complete_rules(&mut ctx)
|
||||
|| complete_params(&mut ctx)
|
||||
|
@ -480,10 +480,12 @@ fn field_access_completions(ctx: &mut CompletionContext, value: &Value, styles:
|
|||
}
|
||||
}
|
||||
|
||||
/// Complete half-finished labels.
|
||||
fn complete_open_labels(ctx: &mut CompletionContext) -> bool {
|
||||
/// Complete labels.
|
||||
fn complete_labels(ctx: &mut CompletionContext) -> bool {
|
||||
// A label anywhere in code: "(<la|".
|
||||
if ctx.leaf.kind().is_error() && ctx.leaf.text().starts_with('<') {
|
||||
if (ctx.leaf.kind().is_error() && ctx.leaf.text().starts_with('<'))
|
||||
|| ctx.leaf.kind() == SyntaxKind::Label
|
||||
{
|
||||
ctx.from = ctx.leaf.offset() + 1;
|
||||
ctx.label_completions();
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue