diff --git a/apps/vscode/CHANGELOG.md b/apps/vscode/CHANGELOG.md index d46e7a98..a9f361b8 100644 --- a/apps/vscode/CHANGELOG.md +++ b/apps/vscode/CHANGELOG.md @@ -2,6 +2,7 @@ ## 1.123.0 (unreleased) +- Fixed a bug with switching between source and visual editors in Positron (). ## 1.122.0 (Release on 2025-05-26) diff --git a/apps/vscode/src/providers/editor/editor.ts b/apps/vscode/src/providers/editor/editor.ts index 8ff5c300..45a7347c 100644 --- a/apps/vscode/src/providers/editor/editor.ts +++ b/apps/vscode/src/providers/editor/editor.ts @@ -175,7 +175,7 @@ export class VisualEditorProvider implements CustomTextEditorProvider { // as the tab in `window.tabGroups`, so if we try and close `tab` we // get a "tab not found" error. The one we care about does exist, but we have // manually find it via URI, which is a stable field to match on. - if (editorMode && editorMode != viewType && !isSwitch) { + if (editorMode && editorMode !== viewType && !isSwitch) { const allTabs = window.tabGroups.all.flatMap(group => group.tabs); // find tab to close if swapping editor type diff --git a/apps/vscode/src/providers/editor/toggle.ts b/apps/vscode/src/providers/editor/toggle.ts index cbb426dd..41361483 100644 --- a/apps/vscode/src/providers/editor/toggle.ts +++ b/apps/vscode/src/providers/editor/toggle.ts @@ -121,6 +121,8 @@ export async function reopenEditorInVisualMode( viewColumn?: ViewColumn ) { if (hasHooks()) { + // note pending switch to visual + VisualEditorProvider.recordPendingSwitchToVisual(document); commands.executeCommand('positron.reopenWith', document.uri, 'quarto.visualEditor'); } else { // save then close @@ -144,6 +146,9 @@ export async function reopenEditorInSourceMode( viewColumn?: ViewColumn ) { if (hasHooks()) { + // note pending switch to source + VisualEditorProvider.recordPendingSwitchToSource(document); + commands.executeCommand('positron.reopenWith', document.uri, 'default'); } else { if (!document.isUntitled) {