-
Notifications
You must be signed in to change notification settings - Fork 742
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
Incsearch support for :global #894
Merged
AlexPl292
merged 36 commits into
JetBrains:master
from
citizenmatt:bugfix/incsearch-for-global
Jun 3, 2024
Merged
Incsearch support for :global #894
AlexPl292
merged 36 commits into
JetBrains:master
from
citizenmatt:bugfix/incsearch-for-global
Jun 3, 2024
Conversation
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
An address evaluates to a line, and a range is a collection of addresses
Sometimes we cache things, and other times it's relative to a passed caret. Let's always calculate it
Remove mutation from LineAddress
Provide caret when calling from Command
Also ensure that test derives from VimTestCase so that injector is correctly initialised
Count needs to be one-based, lines must be zero-based. So store addresses as one-based until processed
Also start to refactor handling of count
Correctly handles some validation, and also allows going to line zero
Validates register before use and correctly uses register and count
Made it explicit to get the count from argument and/or range. Default count is not passed, because it was never used. Added some tests where possible, but hard to test select file and friends
Shift left and right now work with counts, validate the counts and move the caret to the correct end position
Handles validation of count and correctly moves caret to end of range after execution. Also fix issue where the results of :print are accumulated and not cleared. Fixes VIM-2570
Handles validation for count and positions caret in the correct place. Also handles join with visual multicaret scenarios.
Handles validation for count and ensures correct behaviour for registers.
Specify a default range instead of default line for count.
Fixes VIM-2891
Fixes VIM-1137
Fixes VIM-992
This ensures that a failing action doesn't pass due to previous state
Removes a workaround that would break moving a range to the current line because it would always move the caret to the start of the range. Now positions the caret to the start of the selection if there is one. This also means we can remove the SAVE_VISUAL flag from JoinLinesCommand Fixes VIM-2936
We need to share the implementation between starting an Ex command, and starting a filter command, which is just an Ex command with initial text
Commands are executed in Normal mode, although there may be multiple carets
Fixes regression from changes in ex field handling
E.g. `2"a3"b4"c5d6/foo` will now highlight the current match correctly
citizenmatt
force-pushed
the
bugfix/incsearch-for-global
branch
from
May 30, 2024 16:21
a9111f3
to
fa18d23
Compare
Rebased and force pushed. There were some conflicts with recent changes to handling the ex text field, so the last 7 commits should be reviewed again. The conflicts highlighted a bug and a regression, which are also fixed in these last commits. |
Merged! Thank you! |
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.
Well this PR is a great example of yak shaving. I wanted to modify one line in the ex text field change listener to add
instanceof GlobalCommand
so it would update highlights for the:global
command, and, well, this PR happened instead. The big problem is that:global
has a default range of the whole file, where (nearly) all other commands have a default range of the current line, and that wasn't easily added.So, this PR refactors range handling to allow the
:global
command to have a different default range to the other commands. It improves and simplifies the API and uses the same terminology as Vim - a "range" is a collection of "addresses". An address evaluates to a line number, and can be an explicit number, such as1
or2
, or a string like.
for the current line,$
for the last line,'a
for a mark, etc., or even a search pattern. Addresses can also have +/- offsets. The range%
is a collection of the first line to the last line in a file.It also fixes a number of off-by-one errors; addresses are one-based, while IdeaVim internally is zero-based. This is particularly important because the address
0
is special. For the:[range]move {address}
or:[range]copy {address}
command, a value of1
for{address}
means move/copy to the line after the first line, while0
means move/copy to the line before the first line. This{address}
should not be confused with{count}
in:[range]yank {count}
, which is also 1-based, but should be treated as 1-based by IdeaVim.As part of the refactoring, it fixes the following issues:
:[count]goto
to go to the[count]
th character in a file:[range]copy 0
to correctly copy to the line before the first line:>{count}
and:<{count}
:global
command (VIM-2570)0
not being handled correctly, e.g.:0,$s/...
(VIM-1137):1,d
(VIM-992)line()
script function when in Normal mode:[range]m.
move to current line (VIM-2936):copy
,:move
,:goto
(goto character),:[range]
(goto line),:delete
,:join
,:yank
Finally, of course, it adds
'incsearch'
highlighting for the:global
command (VIM-2891).