Fix :| edge case

This commit is contained in:
Christopher Schleiden
2022-11-23 07:08:50 -08:00
parent 1962968440
commit 1e339cb732
2 changed files with 10 additions and 1 deletions
+1 -1
View File
@@ -157,7 +157,7 @@ jobs:
const result = await complete(...getPositionFromCursor(input));
expect(result).not.toBeUndefined();
expect(result.length).toEqual(17);
expect(result.length).toEqual(0);
});
it("custom value providers override defaults", async () => {
+9
View File
@@ -40,6 +40,15 @@ export async function complete(
valueProviderConfig?: ValueProviderConfig,
contextProviderConfig?: ContextProviderConfig
): Promise<CompletionItem[]> {
// Edge case: when completing a key like `foo:|`, do not calculate auto-completions
const charBeforePos = textDocument.getText({
start: {line: position.line, character: position.character - 1},
end: {line: position.line, character: position.character}
});
if (charBeforePos === ":") {
return [];
}
// Fix the input to work around YAML parsing issues
const [newDoc, newPos] = transform(textDocument, position);