Skip to content

Commit 001920a

Browse files
authored
Merge branch 'main' into add-insert-to-editor-action-bar
2 parents c858067 + 8ad5731 commit 001920a

File tree

2 files changed

+42
-35
lines changed

2 files changed

+42
-35
lines changed

apps/vscode/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Change controls on Positron editor action bar and fix "Render on Save" behavior (<https://github.com/quarto-dev/quarto/pull/706>).
66
- Add additional new control ("Insert Code Cell") to Positron editor action bar (<https://github.com/quarto-dev/quarto/pull/709>).
7+
- Turn off completions in visual mode in Positron, as a temporary stopgap until we can invest more in LSP features in the visual editor (<https://github.com/quarto-dev/quarto/pull/710>).
78

89
## 1.121.0 (Release on 2025-05-02)
910

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

Lines changed: 41 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import {
4545
kCodeViewGetCompletions,
4646
} from "editor-types";
4747

48+
import { hasHooks } from "../../host/hooks";
4849
import { embeddedLanguage } from "../../vdoc/languages";
4950
import { virtualDocForCode } from "../../vdoc/vdoc";
5051
import { vdocCompletions } from "../../vdoc/vdoc-completion";
@@ -73,48 +74,53 @@ export function vscodeCodeViewServer(_engine: MarkdownEngine, document: TextDocu
7374
}
7475
},
7576
async codeViewCompletions(context: CodeViewCompletionContext): Promise<CompletionList> {
76-
7777
// if this is yaml then call the lsp directly
7878
if (context.language === "yaml") {
79-
8079
return lspRequest(kCodeViewGetCompletions, [context]);
80+
}
8181

82-
} else {
83-
84-
// see if we have an embedded langaage
85-
const language = embeddedLanguage(context.language);
86-
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+
}
8790

88-
// if this is a yaml comment line then call the lsp
89-
const line = context.code[context.selection.start.line];
90-
if (language.comment && line.startsWith(`${language.comment}| `)) {
91-
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+
}
9296

93-
// otherwise delegate to vscode completion system
94-
} else {
95-
const vdoc = virtualDocForCode(context.code, language);
96-
const completions = await vdocCompletions(
97-
vdoc,
98-
new Position(
99-
context.selection.start.line,
100-
context.selection.start.character
101-
),
102-
undefined,
103-
language,
104-
document.uri
105-
);
106-
return {
107-
items: completions.map(vsCompletionItemToLsCompletionItem),
108-
isIncomplete: false
109-
};
110-
}
111-
} else {
112-
return {
113-
items: [],
114-
isIncomplete: false
115-
};
116-
}
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()) {
101+
return {
102+
items: [],
103+
isIncomplete: false
104+
};
117105
}
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+
};
118124
},
119125
async codeViewPreviewDiagram(state: DiagramState, activate: boolean) {
120126
commands.executeCommand("quarto.previewDiagram", { state, activate });

0 commit comments

Comments
 (0)