Skip to content

Commit 313d865

Browse files
committed
Clarify that this is just a series of potential early exits
1 parent 60f84a3 commit 313d865

File tree

1 file changed

+36
-35
lines changed

1 file changed

+36
-35
lines changed

apps/vscode/src/providers/editor/codeview.ts

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -74,52 +74,53 @@ export function vscodeCodeViewServer(_engine: MarkdownEngine, document: TextDocu
7474
}
7575
},
7676
async codeViewCompletions(context: CodeViewCompletionContext): Promise<CompletionList> {
77-
7877
// if this is yaml then call the lsp directly
7978
if (context.language === "yaml") {
80-
8179
return lspRequest(kCodeViewGetCompletions, [context]);
80+
}
8281

83-
} else {
84-
85-
// see if we have an embedded langaage
86-
const language = embeddedLanguage(context.language);
87-
88-
if (language) {
82+
// see if we have an embedded langaage
83+
const language = embeddedLanguage(context.language);
84+
if (!language) {
85+
return {
86+
items: [],
87+
isIncomplete: false
88+
};
89+
}
8990

90-
// if this is a yaml comment line then call the lsp
91-
const line = context.code[context.selection.start.line];
92-
if (language.comment && line.startsWith(`${language.comment}| `)) {
93-
return lspCellYamlOptionsCompletions(context, lspRequest);
91+
// if this is a yaml comment line then call the lsp
92+
const line = context.code[context.selection.start.line];
93+
if (language.comment && line.startsWith(`${language.comment}| `)) {
94+
return lspCellYamlOptionsCompletions(context, lspRequest);
95+
}
9496

95-
// otherwise delegate to vscode completion system
96-
// is this in Positron? If so, no completions
97-
// TODO: fix LSP issues for visual editor in Positron:
98-
// https://github.com/posit-dev/positron/issues/1805
99-
}
100-
if (!hasHooks()) {
101-
const vdoc = virtualDocForCode(context.code, language);
102-
const completions = await vdocCompletions(
103-
vdoc,
104-
new Position(
105-
context.selection.start.line,
106-
context.selection.start.character
107-
),
108-
undefined,
109-
language,
110-
document.uri
111-
);
112-
return {
113-
items: completions.map(vsCompletionItemToLsCompletionItem),
114-
isIncomplete: false
115-
};
116-
}
117-
}
97+
// if this is Positron, no visual editor completions
98+
// TODO: fix LSP issues for visual editor in Positron:
99+
// https://github.com/posit-dev/positron/issues/1805
100+
if (hasHooks()) {
118101
return {
119102
items: [],
120103
isIncomplete: false
121104
};
122105
}
106+
107+
// otherwise delegate to vscode completion system
108+
const vdoc = virtualDocForCode(context.code, language);
109+
const completions = await vdocCompletions(
110+
vdoc,
111+
new Position(
112+
context.selection.start.line,
113+
context.selection.start.character
114+
),
115+
undefined,
116+
language,
117+
document.uri
118+
);
119+
120+
return {
121+
items: completions.map(vsCompletionItemToLsCompletionItem),
122+
isIncomplete: false
123+
};
123124
},
124125
async codeViewPreviewDiagram(state: DiagramState, activate: boolean) {
125126
commands.executeCommand("quarto.previewDiagram", { state, activate });

0 commit comments

Comments
 (0)