Fix :| edge case
This commit is contained in:
@@ -157,7 +157,7 @@ jobs:
|
|||||||
const result = await complete(...getPositionFromCursor(input));
|
const result = await complete(...getPositionFromCursor(input));
|
||||||
|
|
||||||
expect(result).not.toBeUndefined();
|
expect(result).not.toBeUndefined();
|
||||||
expect(result.length).toEqual(17);
|
expect(result.length).toEqual(0);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("custom value providers override defaults", async () => {
|
it("custom value providers override defaults", async () => {
|
||||||
|
|||||||
@@ -40,6 +40,15 @@ export async function complete(
|
|||||||
valueProviderConfig?: ValueProviderConfig,
|
valueProviderConfig?: ValueProviderConfig,
|
||||||
contextProviderConfig?: ContextProviderConfig
|
contextProviderConfig?: ContextProviderConfig
|
||||||
): Promise<CompletionItem[]> {
|
): 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
|
// Fix the input to work around YAML parsing issues
|
||||||
const [newDoc, newPos] = transform(textDocument, position);
|
const [newDoc, newPos] = transform(textDocument, position);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user