|
13 | 13 | * |
14 | 14 | */ |
15 | 15 |
|
16 | | -import path, { extname } from "path"; |
| 16 | +import path, { extname, win32 } from "path"; |
17 | 17 | import { determineMode } from "./toggle" |
18 | 18 | import debounce from "lodash.debounce"; |
19 | 19 |
|
@@ -58,13 +58,22 @@ import { MarkdownEngine } from "../../markdown/engine"; |
58 | 58 | import { lspClientTransport } from "core-node"; |
59 | 59 | import { editorSourceJsonRpcServer } from "editor-core"; |
60 | 60 | import { JsonRpcRequestTransport } from "core"; |
61 | | -import { |
62 | | - editInSourceModeCommand, |
63 | | - editInVisualModeCommand, |
64 | | - reopenEditorInSourceMode |
| 61 | +import { |
| 62 | + editInSourceModeCommand, |
| 63 | + editInVisualModeCommand, |
| 64 | + reopenEditorInSourceMode |
65 | 65 | } from "./toggle"; |
66 | 66 | import { ExtensionHost } from "../../host"; |
67 | 67 |
|
| 68 | +const labels = [ |
| 69 | + "(Working Tree)", |
| 70 | + "(Deleted)", |
| 71 | + "(Theirs)", |
| 72 | + "(Ours)", |
| 73 | + "(Untracked)", |
| 74 | + "(Intent to add)", |
| 75 | + "(Type changed)" |
| 76 | +]; |
68 | 77 |
|
69 | 78 | export interface QuartoVisualEditor extends QuartoEditor { |
70 | 79 | hasFocus() : Promise<boolean>; |
@@ -146,16 +155,21 @@ export class VisualEditorProvider implements CustomTextEditorProvider { |
146 | 155 | if (!editor) { |
147 | 156 | return; |
148 | 157 | } |
| 158 | + |
149 | 159 | const document = editor.document; |
150 | 160 | if (document && isQuartoDoc(document)) { |
151 | 161 | const uri = document.uri.toString(); |
152 | 162 | // check for switch (one shot) |
153 | 163 | const isSwitch = this.visualEditorPendingSwitchToSource.has(uri); |
154 | 164 |
|
| 165 | + // check to see if this is a git diff. if so, do not try to change editor mode |
| 166 | + const tabLabel = window.tabGroups.activeTabGroup.activeTab?.label |
| 167 | + const isDiff = labels.some(label => tabLabel?.includes(label)) |
| 168 | + |
155 | 169 | // see if user has specified visual or source mode |
156 | 170 | const config = workspace.getConfiguration('quarto').get<string>('defaultEditor'); |
157 | 171 | const editorMode = await determineMode(document); |
158 | | - if (editorMode && editorMode != config && !isSwitch) { |
| 172 | + if (editorMode && editorMode != config && !isSwitch && !isDiff) { |
159 | 173 | const editorOpener = editorMode === 'visual' ? VisualEditorProvider.viewType : 'textEditor'; |
160 | 174 | await commands.executeCommand('workbench.action.closeActiveEditor'); |
161 | 175 | await commands.executeCommand("vscode.openWith", |
|
0 commit comments