-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Fix nextTab/prevTab selection logic #5383
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
Conversation
Hey, you're stealing my PR :-) |
When searching through all tabs, the order was accidentally reversed. This was broken by commit d2bac86 (Remove tab switching logic from Sketch). This also fixes a problem where "replace all" would only work on the first and last tab (since it would search backwards from the first tab to the last tab and then conclude it was done). This fixes a part of arduino#5380.
c09c154
to
c927237
Compare
I stole it back, I replaced my commit with yours. Content is identical, but my commit message was a bit more complete :-) |
LOL 😄 |
The snippet: boolean wrapNeeded = false; if (wrap && nextIndex == -1) { // if wrapping, a second chance is ok, start from the end wrapNeeded = true; } is present on both sides of the `if` statement so it can be factored out.
The snippet: boolean wrapNeeded = false; if (wrap && nextIndex == -1) { // if wrapping, a second chance is ok, start from the end wrapNeeded = true; } Can be moved inside the `if (nextIndex == -1)` that follows, this way: if (nextIndex == -1) { boolean wrapNeeded = false; if (wrap) { // if wrapping, a second chance is ok, start from the end wrapNeeded = true; } [...CUT...] if (wrapNeeded) { nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0); } } but since `wrapNeeded` is used only at the very end of the `if` statement we can move it forward: if (nextIndex == -1) { [...CUT...] boolean wrapNeeded = false; if (wrap) { // if wrapping, a second chance is ok, start from the end wrapNeeded = true; } if (wrapNeeded) { nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0); } } and finally simplify it by removing `wrapNeeded` altogether: if (nextIndex == -1) { [...CUT...] if (wrap) { nextIndex = backwards ? text.lastIndexOf(search) : text.indexOf(search, 0); } }
I've pushed some more commits that solves the highlight bug and fix another corner case with foldings. |
cba11e2
to
1efa07f
Compare
@cmaglie, awesome, thanks for digging into this. Commits look great to me, I especially like the long commit messages on the cleanup commits :-D |
fixes #5380