Open
Conversation
…when detected changes to the backing file match what's in the buffer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a blocker for pulsar#1478, which I'd tentatively targeted for version 1.132.0. So it's not a drop-everything-and-review sort of thing, but I'd appreciate if someone took a look at this after we ship 1.131.2.
This is a bit esoteric, but imagine this scenario:
TextBufferbacked by a file on diskdid-conflictevent, and set a flag (fileHasChangedSinceLastLoad) totrueto mark the file as conflictedisInConflictmethod will thereafter returntrue, as it will whenever (a)fileHasChangedSinceLastLoadistrueand (b)isModified()returnstrueOnce you save the file again,
fileHasChangedSinceLastLoadedis reset tofalse, since that serves to synchronize the buffer contents and the file contents. Even if you modify the buffer again after saving,isInConflictwill correctly returnfalse, sincefileHasChangedSinceLastLoadedis stillfalse.But here's a scenario that slipped through the specs:
TextBufferbacked by a file on diskfileHasChangedSinceLastLoadflips totrueeven though the file isn't actually in conflict (anddid-conflictwas not emitted)isInConflictmethod's test are nowtrue, and the buffer is treated as being in conflict even though it isn'tI think the idea was that the other code paths through the
onDidChangehandler were eventually supposed to result infileHasChangedSinceLastLoadedflipping back tofalse… but in practice, we take one of the side doors instead, and return early before the line infinishLoadingthat actually resets the flag.In practice, the changes in pulsar#1478 cause the new “this file is in conflict; are you sure you want to save?” dialog to fire much too often… because
isInConflictis incorrectly returningtruepractically all the time after the initial save to disk.This PR should fix this. There are probably a couple different approaches I could've taken for this, but I went with the one that I knew I could reason about correctly: in the code paths in
onDidChangewhere we know the buffer contents are synchronized with what's on disk, we'll proactively flipfileHasChangedSinceLastLoadback tofalse.Testing
The first commit changes an existing spec to demonstrate the problem; if you check out just that commit, the spec will fail.
The next commit makes the failing spec pass again.