@@ -52,7 +52,7 @@ describe('MergeSessionCoordinator', () => {
5252 testDataHandler . dispose ( ) ;
5353 } ) ;
5454
55- it ( 'finalizes merge on save and refreshes solution ' , async ( ) => {
55+ it ( 'refreshes on save without destructive file operations ' , async ( ) => {
5656 const local = path . join ( tmpDir , 'component.c' ) ;
5757 const update = path . join ( tmpDir , 'component.c.update@1.0.0' ) ;
5858 const base = path . join ( tmpDir , 'component.c.base@1.0.0' ) ;
@@ -69,12 +69,12 @@ describe('MergeSessionCoordinator', () => {
6969 handleDidSaveTextDocument : ( document : vscode . TextDocument ) => Promise < void >
7070 } ) . handleDidSaveTextDocument ( { uri : { fsPath : merged } } as vscode . TextDocument ) ;
7171
72- const newBase = path . join ( tmpDir , 'component.c.base@1.0.0' ) ;
73- expect ( fsUtils . fileExists ( `${ local } .bak` ) ) . toBeTruthy ( ) ;
7472 expect ( fsUtils . fileExists ( local ) ) . toBeTruthy ( ) ;
75- expect ( fsUtils . readTextFile ( local ) ) . toContain ( '// merged' ) ;
76- expect ( fsUtils . fileExists ( merged ) ) . toBeFalsy ( ) ;
77- expect ( fsUtils . fileExists ( newBase ) ) . toBeTruthy ( ) ;
73+ expect ( fsUtils . readTextFile ( local ) ) . toContain ( '// local' ) ;
74+ expect ( fsUtils . fileExists ( merged ) ) . toBeTruthy ( ) ;
75+ expect ( fsUtils . fileExists ( base ) ) . toBeTruthy ( ) ;
76+ expect ( fsUtils . fileExists ( update ) ) . toBeTruthy ( ) ;
77+ expect ( fsUtils . fileExists ( `${ local } .bak` ) ) . toBeFalsy ( ) ;
7878
7979 expect ( solutionManager . refresh ) . toHaveBeenCalledTimes ( 1 ) ;
8080 } ) ;
@@ -100,6 +100,28 @@ describe('MergeSessionCoordinator', () => {
100100 expect ( fsUtils . fileExists ( merged ) ) . toBeTruthy ( ) ;
101101 } ) ;
102102
103+ it ( 'does not refresh on save after session is canceled' , async ( ) => {
104+ const local = path . join ( tmpDir , 'component.c' ) ;
105+ const update = path . join ( tmpDir , 'component.c.update@1.0.0' ) ;
106+ const base = path . join ( tmpDir , 'component.c.base@1.0.0' ) ;
107+ const merged = `${ local } .merged` ;
108+
109+ fsUtils . writeTextFile ( local , '// local\n' ) ;
110+ fsUtils . writeTextFile ( update , '// update\n' ) ;
111+ fsUtils . writeTextFile ( base , '// base\n' ) ;
112+ fsUtils . writeTextFile ( merged , '// merged\n' ) ;
113+
114+ coordinator . startSession ( { local, update, base, merged, mergedMTimeBefore : 0 } ) ;
115+ coordinator . cancelSession ( ) ;
116+
117+ await ( coordinator as unknown as {
118+ handleDidSaveTextDocument : ( document : vscode . TextDocument ) => Promise < void >
119+ } ) . handleDidSaveTextDocument ( { uri : { fsPath : merged } } as vscode . TextDocument ) ;
120+
121+ expect ( solutionManager . refresh ) . not . toHaveBeenCalled ( ) ;
122+ expect ( fsUtils . fileExists ( merged ) ) . toBeTruthy ( ) ;
123+ } ) ;
124+
103125 it ( 'finalizes on merge process exit when save hook did not run' , async ( ) => {
104126 const local = path . join ( tmpDir , 'component.c' ) ;
105127 const update = path . join ( tmpDir , 'component.c.update@1.0.0' ) ;
0 commit comments