-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
[RFC] Make inccomand work with multiline substitutions #7231
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
So, the approach of having a |
4f72361
to
8b9c2ad
Compare
Ok, this looks much better, though it's still wrong (I add too many matches somehow, and the preview window isn't shown). Still going :) |
70de238
to
9aaac75
Compare
How the hell did the previous incarnation pass the tests on appveyor O_o Anyways, logic seems sortof solid now, expect for that special casing https://github.com/neovim/neovim/pull/7231/files#diff-b9d70f1e57978ae9fbf83f73315b0c0fR3690. Next step will be to try to display the correct things in the preview window. |
9aaac75
to
78fde77
Compare
I did try some things, and now I've settled on a design I like. I'll do a bit of description below, if anyone does not think it appropriate please let me know. Status right now: Builds, works in simple manual tries, previews, but does not yet highlight. I'll first need to try some more elaborate substitutions, and then work on highlighting. Design: I do as little as possible in Of course, comments welcome :) |
4073ea8
to
de38dce
Compare
Ok, the code is a mess, it will kindof spam your log file... BUT it's working, as far as I can see. Highlighting can be pretty weird with complex substitutions, but as far as I can see, it's correct. So, I'd be happy for anyone to try this. I'd especially be interested in "Multi"-Situations: Multiple matches on a line, multiple-line-matches, multiple-line-substitutions, multiple-size-machtches, multiple-size-replacements, you name it! Really though, the most useful would be a report from someone using Multibyte chars, I'll basically have to research how to input them to begin with... |
src/nvim/ex_cmds.c
Outdated
static linenr_T pre_started; | ||
static linenr_T pre_ended; | ||
static int pre_src_id; // initialized to 0, see | ||
// https://stackoverflow.com/questions/13251083 |
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.
could be explicit, and avoid the comment :)
static int pre_src_id = 0;
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.
Usually we put static locals at the very start of a function. I think it would be surprising to see them in the middle of other locals.
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.
About that explizit, I'm not sure about the semantics. I don't want it to be reset to 0 every time the function is called, of course. That won't happen?
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.
@KillTheMule won't happen. static locals are initialized only once for the life of the process.
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.
Which, thinking about it, makes sense! Thanks, I'll change that.
de38dce
to
9a8b750
Compare
Fixed the old tests and an outstanding issue. Also started writing new tests. I'm baffled that the new tests 8d4efc8#diff-ddcc7112118dfbcc54565044d90602eb also pass on master. When I try this manually on current master, nvim locks up and the substitution does not happen, so the expect should fail. But the tests do pass... |
9a8b750
to
8d4efc8
Compare
ff6a3c0
to
9321b9b
Compare
Fixed a lot of bugs during writing the tests. Basically it is polished enough for a review, although I definitely want to simplify the highlighting logic in If anyone can think of another test to be added, I'd be happy to hear it. |
3b845d7
to
a0a144d
Compare
d35813d
to
8fca927
Compare
Make inccomand work with multiline patterns and substitutions. Also care for proper highlighting and multibyte characters.
8fca927
to
10f31c2
Compare
They were only used to not show the preview window when typing "s/" or "s//" only, in which case the previous pattern would be reused. Now the window is shown in that case.
It would always show an empty line at the end that didn't belong.
... that does not have that superflous last line. Also, remove some indeterminism for the freebsd64 tests. Partially, those were suggested by the tests themselves, while successfull. Some of them were added after some testing because the lookaround test would fail on freebsd64 only.
10f31c2
to
d8cdf2f
Compare
I've added another little fix: The preview buffer would always show one superflous line (I guess that was the one that's added to a buffer upon creation). I removed that, and therefore had to adjust quite some tests. |
I've had to put in a bug fix, I'm gonna leave this as separate commits. |
Merged in #7315 |
Inccomand substitution now properly works with multiline matches and substitutions, handles multibyte stuff and does highlighting.
inccommand_spec.lua
TODO for later:
Closes #5608.