@@ -512,19 +512,22 @@ describe("DiffViewProvider", () => {
512512 return { isPreview, input, label : fsPath }
513513 }
514514
515- const setTabs = ( tabs : any [ ] ) => {
515+ const setTabs = ( tabs : any [ ] , viewColumn = vscode . ViewColumn . One ) => {
516516 Object . defineProperty ( vscode . window . tabGroups , "all" , {
517- get : ( ) => [ { tabs } ] ,
517+ get : ( ) => [ { tabs, viewColumn } ] ,
518518 configurable : true ,
519519 } )
520520 }
521521
522- it ( "captures unrelated preview tabs with their scroll position, excluding the diff target" , ( ) => {
523- setTabs ( [
524- makePreviewTab ( "/mock/cwd/file-1.txt" ) ,
525- makePreviewTab ( "/mock/cwd/file-2.txt" ) , // diff target -- excluded
526- makePreviewTab ( "/mock/cwd/file-3.txt" , false ) , // not a preview -- excluded
527- ] )
522+ it ( "captures unrelated preview tabs with their scroll position and group, excluding the diff target" , ( ) => {
523+ setTabs (
524+ [
525+ makePreviewTab ( "/mock/cwd/file-1.txt" ) ,
526+ makePreviewTab ( "/mock/cwd/file-2.txt" ) , // diff target -- excluded
527+ makePreviewTab ( "/mock/cwd/file-3.txt" , false ) , // not a preview -- excluded
528+ ] ,
529+ vscode . ViewColumn . Two ,
530+ )
528531 vi . mocked ( vscode . window ) . visibleTextEditors = [
529532 {
530533 document : { uri : { fsPath : "/mock/cwd/file-1.txt" , scheme : "file" } } ,
@@ -537,22 +540,23 @@ describe("DiffViewProvider", () => {
537540 expect ( snapshot ) . toHaveLength ( 1 )
538541 expect ( snapshot [ 0 ] . uri . fsPath ) . toBe ( "/mock/cwd/file-1.txt" )
539542 expect ( snapshot [ 0 ] . scrollLine ) . toBe ( 12 )
543+ expect ( snapshot [ 0 ] . viewColumn ) . toBe ( vscode . ViewColumn . Two )
540544 } )
541545
542- it ( "restores an evicted preview tab in preview mode and reapplies its scroll position" , async ( ) => {
546+ it ( "restores an evicted preview tab in its original group and reapplies its scroll position" , async ( ) => {
543547 const revealRange = vi . fn ( )
544548 vi . mocked ( vscode . window . showTextDocument ) . mockResolvedValue ( { revealRange } as any )
545549 // The captured file is no longer open (evicted by the diff).
546550 setTabs ( [ ] )
547551 ; ( diffViewProvider as any ) . snapshotPreviewTabs = [
548- { uri : { fsPath : "/mock/cwd/file-1.txt" , scheme : "file" } , scrollLine : 12 } ,
552+ { uri : { fsPath : "/mock/cwd/file-1.txt" , scheme : "file" } , scrollLine : 12 , viewColumn : vscode . ViewColumn . Two } ,
549553 ]
550554
551555 await ( diffViewProvider as any ) . restorePreviewTabs ( )
552556
553557 expect ( vscode . window . showTextDocument ) . toHaveBeenCalledWith (
554558 { fsPath : "/mock/cwd/file-1.txt" , scheme : "file" } ,
555- { preview : true , preserveFocus : true } ,
559+ { preview : true , preserveFocus : true , viewColumn : vscode . ViewColumn . Two } ,
556560 )
557561 expect ( revealRange ) . toHaveBeenCalledWith (
558562 expect . objectContaining ( { start : { line : 12 , character : 0 } } ) ,
@@ -564,7 +568,7 @@ describe("DiffViewProvider", () => {
564568 it ( "does not restore a preview tab that is still open" , async ( ) => {
565569 setTabs ( [ makePreviewTab ( "/mock/cwd/file-1.txt" ) ] )
566570 ; ( diffViewProvider as any ) . snapshotPreviewTabs = [
567- { uri : { fsPath : "/mock/cwd/file-1.txt" , scheme : "file" } , scrollLine : 0 } ,
571+ { uri : { fsPath : "/mock/cwd/file-1.txt" , scheme : "file" } , scrollLine : 0 , viewColumn : vscode . ViewColumn . One } ,
568572 ]
569573
570574 await ( diffViewProvider as any ) . restorePreviewTabs ( )
@@ -577,7 +581,7 @@ describe("DiffViewProvider", () => {
577581 const fs = await import ( "fs/promises" )
578582 vi . mocked ( fs . access ) . mockRejectedValueOnce ( new Error ( "ENOENT" ) )
579583 ; ( diffViewProvider as any ) . snapshotPreviewTabs = [
580- { uri : { fsPath : "/mock/cwd/deleted.txt" , scheme : "file" } , scrollLine : 0 } ,
584+ { uri : { fsPath : "/mock/cwd/deleted.txt" , scheme : "file" } , scrollLine : 0 , viewColumn : vscode . ViewColumn . One } ,
581585 ]
582586
583587 await ( diffViewProvider as any ) . restorePreviewTabs ( )
0 commit comments