Skip to content

Commit 904df9f

Browse files
authored
Enhance DiffViewProvider to preserve focus when opening text documents (RooCodeInc#3346)
1 parent ca3cf18 commit 904df9f

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,7 @@ export class DiffViewProvider {
202202

203203
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
204204
preview: false,
205+
preserveFocus: true,
205206
})
206207
await this.closeAllDiffViews()
207208

@@ -302,6 +303,7 @@ export class DiffViewProvider {
302303
if (this.documentWasOpen) {
303304
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
304305
preview: false,
306+
preserveFocus: true,
305307
})
306308
}
307309
await this.closeAllDiffViews()
@@ -338,7 +340,9 @@ export class DiffViewProvider {
338340
arePathsEqual(tab.input.modified.fsPath, uri.fsPath),
339341
)
340342
if (diffTab && diffTab.input instanceof vscode.TabInputTextDiff) {
341-
const editor = await vscode.window.showTextDocument(diffTab.input.modified)
343+
const editor = await vscode.window.showTextDocument(diffTab.input.modified, {
344+
preserveFocus: true,
345+
})
342346
return editor
343347
}
344348
// Open new diff editor
@@ -358,6 +362,9 @@ export class DiffViewProvider {
358362
}),
359363
uri,
360364
`${fileName}: ${fileExists ? "Original ↔ Cline's Changes" : "New File"} (Editable)`,
365+
{
366+
preserveFocus: true,
367+
},
361368
)
362369
// This may happen on very slow machines ie project idx
363370
setTimeout(() => {

0 commit comments

Comments
 (0)