Skip to content

Commit

Permalink
[#73476] improve filtering completions
Browse files Browse the repository at this point in the history
  • Loading branch information
Trzcin committed Feb 24, 2025
1 parent aed2ad0 commit 68df376
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/extensions/yamlSchema.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,10 @@ export const yamlSchema = (schema, editorView, linter) => {
if (ctx.pos !== line.to) return;

const items = completions.items ?? completions;
const token = ctx.matchBefore(/\w+/);
const token = ctx.matchBefore(/^.*/m);
const tokenSplit = token ? token.text.trimStart().split(": ") : null;
const completionStart = token ? tokenSplit[tokenSplit.length - 1] : null;
const property = !token || tokenSplit.length === 1;
const options = items
.map(({ detail, label, kind, textEdit, documentation }) => ({
label,
Expand All @@ -128,7 +131,7 @@ export const yamlSchema = (schema, editorView, linter) => {
});
},
}))
.filter(({ type, label }) => type !== "class" && (!token || label.startsWith(token.text)));
.filter(({ type, label }) => type !== "class" && (type !== "property" || property) && (!token || label.startsWith(completionStart)));
return { from: ctx.pos, to: ctx.pos, options, filter: false };
},
},
Expand Down

0 comments on commit 68df376

Please sign in to comment.