@@ -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 ,
0 commit comments