This repository has been archived by the owner on Dec 15, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 194
Only emit did-update when there are changes; set consistent classes on error #852
Open
winstliu
wants to merge
8
commits into
master
Choose a base branch
from
wl-check-for-markers
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 5 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
64b6a20
Don't try to update markers if there's no new markers
winstliu f1aa436
Fix deceptive class when an error occurs
winstliu 53db29a
Add a spec
winstliu 5fa4b3b
Add spec for has-no-results
winstliu e81f8df
Add tests to prevent superfluous update events
winstliu e4c3c4b
Revert "Don't try to update markers if there's no new markers"
winstliu 0d07d56
Revert "Add tests to prevent superfluous update events"
winstliu 9e8e75b
:art:
winstliu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -224,6 +224,8 @@ class BufferSearch { | |
} | ||
|
||
const newMarkers = this.createMarkers(scanStart, scanEnd); | ||
if(newMarkers === false || !newMarkers.length) return; // Invalid/missing find pattern or no new markers | ||
|
||
const oldMarkers = this.markers.splice(spliceStart, (spliceEnd - spliceStart) + 1, ...newMarkers); | ||
for (let oldMarker of oldMarkers) { | ||
oldMarker.destroy(); | ||
|
@@ -237,7 +239,7 @@ class BufferSearch { | |
} | ||
} | ||
|
||
this.emitter.emit('did-update', this.markers.slice()); | ||
if(changes.length) this.emitter.emit('did-update', this.markers.slice()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 This makes a lot of sense. We don't have JS linting enabled on this repo, but usually we include a space after the word |
||
this.currentResultMarker = null; | ||
this.setCurrentMarkerFromSelection(); | ||
} | ||
|
This file contains 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
This file contains 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
This file contains 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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if there are no new markers, we still might want to destroy some old markers, and we certainly want to continue processing the other entries in
changes
, because they might cause us to find new markers.For example, suppose your editor was in this configuration (cursors represented by
|
):and you were searching for the pattern
two|four
and typed abackspace
. That would destroy the match on line 2 but create a match on line 4.In that situation, we wouldn't to return early from
bufferStoppedChanging
just because we didn't find any new markers in the first changed region.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think what we might want to do is make the
createMarkers
return an empty array if no matches were found in the given range.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We've fixed this as part of #860. Didn't mean to steal your 🌩 but we're on a spree of uncaught exception fixes after publishing 1.14.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the other part of this PR is still worthwhile though!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I thought I noticed a regression related to that, but didn't realize what the steps to reproduce were.
I'll update this PR to only focus on the UX changes.