File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -408,6 +408,13 @@ describe('TextBuffer IO', () => {
408408 expect ( buffer . isInConflict ( ) ) . toBe ( true )
409409 await buffer . save ( )
410410 expect ( buffer . isInConflict ( ) ) . toBe ( false )
411+ // Ensure we don't get flipped into conflicted status after the
412+ // `onDidChange` handler comes through…
413+ await wait ( 1000 )
414+ expect ( buffer . isInConflict ( ) ) . toBe ( false )
415+ buffer . setText ( 'q' )
416+ // …and the buffer is modified again.
417+ expect ( buffer . isInConflict ( ) ) . toBe ( false )
411418 done ( )
412419 } )
413420 } )
Original file line number Diff line number Diff line change @@ -2273,9 +2273,20 @@ class TextBuffer {
22732273 if ( this . isModified ( ) ) {
22742274 const source = this . file . getPath ( )
22752275 if ( ! ( await this . buffer . baseTextMatchesFile ( source , this . getEncoding ( ) ) ) ) {
2276+ // Emit `did-conflict` and take no other action. We will keep the
2277+ // current buffer contents so that the user's changes are not lost.
22762278 this . emitter . emit ( 'did-conflict' )
2279+ } else {
2280+ // Despite being modified, we're once again in alignment with what
2281+ // is on disk. This file is not in conflict.
2282+ this . fileHasChangedSinceLastLoad = false
22772283 }
22782284 } else {
2285+ // This buffer was previously in sync with what was on disk, so we
2286+ // can update its contents to match the new contents on disk. By
2287+ // definition, this means there is no conflict, so we'll reset the
2288+ // appropriate flag.
2289+ this . fileHasChangedSinceLastLoad = false
22792290 return this . load ( { internal : true } )
22802291 }
22812292 } , this . fileChangeDelay ) ) )
You can’t perform that action at this time.
0 commit comments