Skip to content

Commit db90f5e

Browse files
committed
Focus improvements
1 parent 4b4f9fe commit db90f5e

File tree

6 files changed

+128
-95
lines changed

6 files changed

+128
-95
lines changed

src/integrations/editor/DiffViewProvider.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ export class DiffViewProvider {
185185
await updatedDocument.save()
186186
}
187187

188-
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false })
188+
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false, preserveFocus: true })
189189
await this.closeAllDiffViews()
190190

191191
// Getting diagnostics before and after the file edit is a better approach than
@@ -285,7 +285,10 @@ export class DiffViewProvider {
285285
console.log(`File ${absolutePath} has been reverted to its original content.`)
286286

287287
if (this.documentWasOpen) {
288-
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), { preview: false })
288+
await vscode.window.showTextDocument(vscode.Uri.file(absolutePath), {
289+
preview: false,
290+
preserveFocus: true,
291+
})
289292
}
290293

291294
await this.closeAllDiffViews()
@@ -332,14 +335,15 @@ export class DiffViewProvider {
332335
)
333336

334337
if (diffTab && diffTab.input instanceof vscode.TabInputTextDiff) {
335-
const editor = await vscode.window.showTextDocument(diffTab.input.modified)
338+
const editor = await vscode.window.showTextDocument(diffTab.input.modified, { preserveFocus: true })
336339
return editor
337340
}
338341

339342
// Open new diff editor.
340343
return new Promise<vscode.TextEditor>((resolve, reject) => {
341344
const fileName = path.basename(uri.fsPath)
342345
const fileExists = this.editType === "modify"
346+
343347
const disposable = vscode.window.onDidChangeActiveTextEditor((editor) => {
344348
if (editor && arePathsEqual(editor.document.uri.fsPath, uri.fsPath)) {
345349
disposable.dispose()
@@ -354,6 +358,7 @@ export class DiffViewProvider {
354358
}),
355359
uri,
356360
`${fileName}: ${fileExists ? "Original ↔ Roo's Changes" : "New File"} (Editable)`,
361+
{ preserveFocus: true },
357362
)
358363

359364
// This may happen on very slow machines i.e. project idx.
@@ -387,7 +392,7 @@ export class DiffViewProvider {
387392

388393
for (const part of diffs) {
389394
if (part.added || part.removed) {
390-
// Found the first diff, scroll to it
395+
// Found the first diff, scroll to it.
391396
this.activeDiffEditor.revealRange(
392397
new vscode.Range(lineCount, 0, lineCount, 0),
393398
vscode.TextEditorRevealType.InCenter,

webview-ui/src/__tests__/utils/command-validation.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/* eslint-disable no-useless-escape */
2+
/* eslint-disable no-template-curly-in-string */
3+
14
import { parseCommand, validateCommand } from "../../utils/command-validation"
25

36
/**

0 commit comments

Comments
 (0)