New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent search result from being deselected if it is the only result #2491
Conversation
remove leading whitespace prevent single search term deselection in findPrevious
@miggs125 sorry I just overwrote your commit. I think the test I added should be good now, what was that last commit you added on? |
@Tyriar for some reason the tests you added are passing on my local copy of the repo but not for the CI tests, not sure what is going on here. |
@@ -97,6 +97,9 @@ export class SearchAddon implements ITerminalAddon { | |||
} | |||
} | |||
|
|||
// If there is only one result, return false. | |||
if (!result && currentSelection) return false; |
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.
The test fails for me, it's because it returns false if there's no selection. I think what we actually want to do is return true instead, this make sense since we succeeded but just didn't touch the selection as it would be redundant to do so.
@@ -59,12 +59,12 @@ export class SearchAddon implements ITerminalAddon { | |||
|
|||
let startCol = 0; | |||
let startRow = 0; | |||
|
|||
let currentSelection = null; |
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.
Let's make this let currentSelect: ISelectionPosition | undefined
, using undefined saves us from initializing it.
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.
Looks great, merging after CI passes 👌
fixes #2456
Prevents single results from being deselected after pressing enter multiple times on a successful search. I couldn't find tests for addons so I wasn't sure if some needed to be made. I will be happy to include them if they are needed.