Skip to content

Improved (less aggressive) editor focus preservation behavior #699

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 2 commits into from
Apr 20, 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.121.0 (unreleased)

- Add new controls for Positron editor action bar (<https://github.com/quarto-dev/quarto/pull/698>).
- Improve editor focus preservation behavior (<https://github.com/quarto-dev/quarto/pull/699>).

## 1.120.0 (Release on 2025-04-07)

Expand Down
18 changes: 10 additions & 8 deletions apps/vscode/src/providers/preview/preview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,13 @@ export async function previewDoc(
previewManager.setOnShow(onShow);
}

// activate the editor
if (!isNotebook(editor.document)) {
await editor.activate();
}

// if this wasn't a renderOnSave then save
// if this wasn't a renderOnSave then activate the editor and save
if (!renderOnSave) {
// activate the editor
if (!isNotebook(editor.document)) {
await editor.activate();
}

await commands.executeCommand("workbench.action.files.save");
if (editor.document.isDirty) {
return;
Expand Down Expand Up @@ -247,8 +247,10 @@ export async function previewDoc(
);

// focus the editor (sometimes the terminal steals focus)
if (!isNotebook(previewEditor.document)) {
await previewEditor.activate();
if (!renderOnSave) {
if (!isNotebook(previewEditor.document)) {
await previewEditor.activate();
}
}
}
}
Expand Down
1 change: 0 additions & 1 deletion apps/vscode/src/providers/webview.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ export class QuartoWebviewManager<T extends QuartoWebview<S>, S> {
if (this.activeView_) {
this.activeView_.reveal();
this.resolveOnShow();
preserveEditorFocus();
}
}

Expand Down