diff --git a/apps/vscode/CHANGELOG.md b/apps/vscode/CHANGELOG.md index 7cf02566..0202508c 100644 --- a/apps/vscode/CHANGELOG.md +++ b/apps/vscode/CHANGELOG.md @@ -2,6 +2,8 @@ ## 1.126.0 (Unreleased) +- Fixed a bug opening non-Quarto files in visual mode on saving (). + ## 1.125.0 (Release on 2025-09-03) - Fixed an issue where attribute values containing '='s could be truncated in some scenarios (). diff --git a/apps/vscode/src/providers/editor/toggle.ts b/apps/vscode/src/providers/editor/toggle.ts index c9508177..c189a415 100644 --- a/apps/vscode/src/providers/editor/toggle.ts +++ b/apps/vscode/src/providers/editor/toggle.ts @@ -129,18 +129,18 @@ export async function reopenEditorInVisualMode( // reopen in visual mode commands.executeCommand('positron.reopenWith', document.uri, 'quarto.visualEditor'); } else { - workspace.onDidSaveTextDocument(async (doc: TextDocument) => { - // open in visual mode - VisualEditorProvider.recordPendingSwitchToVisual(doc); - await commands.executeCommand('workbench.action.closeActiveEditor'); - await commands.executeCommand("vscode.openWith", - doc.uri, - VisualEditorProvider.viewType, - { viewColumn } - ); - }); - // save, which will trigger `onDidSaveTextDocument` + // save then close await commands.executeCommand("workbench.action.files.save"); + await commands.executeCommand('workbench.action.closeActiveEditor'); + VisualEditorProvider.recordPendingSwitchToVisual(document); + + // open in visual mode + await commands.executeCommand( + "vscode.openWith", + document.uri, + VisualEditorProvider.viewType, + { viewColumn } + ); } }