Skip to content

Turn off visual mode completions in Positron #710

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/vscode/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 1.122.0 (unreleased)

- Change controls on Positron editor action bar and fix "Render on Save" behavior (<https://github.com/quarto-dev/quarto/pull/706>).
- 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>).

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

Expand Down
76 changes: 41 additions & 35 deletions apps/vscode/src/providers/editor/codeview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import {
kCodeViewGetCompletions,
} from "editor-types";

import { hasHooks } from "../../host/hooks";
import { embeddedLanguage } from "../../vdoc/languages";
import { virtualDocForCode } from "../../vdoc/vdoc";
import { vdocCompletions } from "../../vdoc/vdoc-completion";
Expand Down Expand Up @@ -73,48 +74,53 @@ export function vscodeCodeViewServer(_engine: MarkdownEngine, document: TextDocu
}
},
async codeViewCompletions(context: CodeViewCompletionContext): Promise<CompletionList> {

// if this is yaml then call the lsp directly
if (context.language === "yaml") {

return lspRequest(kCodeViewGetCompletions, [context]);
}

} else {

// see if we have an embedded langaage
const language = embeddedLanguage(context.language);
if (language) {
// see if we have an embedded langaage
const language = embeddedLanguage(context.language);
if (!language) {
return {
items: [],
isIncomplete: false
};
}

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

// otherwise delegate to vscode completion system
} else {
const vdoc = virtualDocForCode(context.code, language);
const completions = await vdocCompletions(
vdoc,
new Position(
context.selection.start.line,
context.selection.start.character
),
undefined,
language,
document.uri
);
return {
items: completions.map(vsCompletionItemToLsCompletionItem),
isIncomplete: false
};
}
} else {
return {
items: [],
isIncomplete: false
};
}
// if this is Positron, no visual editor completions
// TODO: fix LSP issues for visual editor in Positron:
// https://github.com/posit-dev/positron/issues/1805
if (hasHooks()) {
return {
items: [],
isIncomplete: false
};
}

// otherwise delegate to vscode completion system
const vdoc = virtualDocForCode(context.code, language);
const completions = await vdocCompletions(
vdoc,
new Position(
context.selection.start.line,
context.selection.start.character
),
undefined,
language,
document.uri
);

return {
items: completions.map(vsCompletionItemToLsCompletionItem),
isIncomplete: false
};
},
async codeViewPreviewDiagram(state: DiagramState, activate: boolean) {
commands.executeCommand("quarto.previewDiagram", { state, activate });
Expand Down