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
inccommand: fix for wrapping of large string in preview mode #8283
Conversation
src/nvim/ex_docmd.c
Outdated
@@ -577,6 +577,14 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, | |||
++RedrawingDisabled; | |||
did_inc = TRUE; | |||
} | |||
if (State & CMDPREVIEW) { |
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 could also add the condition in the above if stmt to check for CMDPREVIEW
, and remove the DOCMD_NOWAIT from the part where this function will be called, for the case of previewable
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.
If there is need to shorten the code that would be good
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.
changing the above would be better. why did you removed ++no_wait_return
?
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 did this because, I thought that for the completion of the preview command, there is finally need of a return, as told on Gitter, it NOWAIT was for hiding the Press Enter...
error message.
Mostly this was I think work was of hit and trial, how I reached this, I had the idea that the code that will execute the Inccommand, so I tried to remove the DOCMD_NOWAIT it worked a little bit, but just give the notice Press Return or another key ...
, so to remove this msg, I found the code what extra will happen if DOCMD_NOWAIT flag is given, I found out, and tried to hack code there, as described above using some common sense of the inccommands and a little bit about the functions which will be triggered by reading the comments, I had a lucky guess.
0d341b5
to
745f904
Compare
What about the tests of this PR, means it was a bug fix, how should i add tests. |
src/nvim/ex_getln.c
Outdated
@@ -1911,7 +1911,7 @@ static int command_line_changed(CommandLineState *s) | |||
// - Immediately undo the effects. | |||
State |= CMDPREVIEW; | |||
emsg_silent++; // Block error reporting as the command may be incomplete | |||
do_cmdline(ccline.cmdbuff, NULL, NULL, DOCMD_KEEPLINE|DOCMD_NOWAIT); |
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.
Can't we keep this and instead add State & CMDPREVIEW
as an alternative in the enclosing if-statement?
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 try to think of it as I reach room, now in class
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.
By keeping DOCMD_NOWAIT
, it means that the if part in ex_docmd.c
will not work, I want that the if part should work, but only no_wait_return
should not be incremented, if I have to edit it, the condition in if will become so messy, and according to my personal opinion, I don't like to read a messy, complicated and big condition, so I put this like the way.
Other alternative which I think that was good, was making a separate if condition for State & CMDPREVIEW
but according to @justinmk its also not too better, so this option was left, which I thought was acceptable.
What are the views on 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.
But this is a no-wait state, just like async and <Cmd>
commands in cmdline mode. Just having this flag silently missing when it is expected is also messy.
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.
Okk, then its an issue, then making the condition edit is better.
As this is a visual glitch it should use a screen test. Follow the pattern of the existing screen tests in |
Ok |
For the time you analyze it further, I create the test for the this PR |
4c4f4ac
to
f17729d
Compare
src/nvim/ex_docmd.c
Outdated
@@ -568,14 +568,19 @@ int do_cmdline(char_u *cmdline, LineGetter fgetline, | |||
* from a script or when being called recursive (e.g. for ":e | |||
* +command file"). | |||
*/ | |||
if (!(flags & DOCMD_NOWAIT) && !recursive) { | |||
bool isPreview = (State & CMDPREVIEW) == 0 ? false : true; |
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.
(State & CMDPREVIEW) == 0
evaluates to boolean, no need to use a ternary. !!(State & CMDPREVIEW)
is also a common idiom.
Also we don't use camelCase , so name would be is_preview
.
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.
Okk, !!(State & CMDPREVIEW)
is good, new style for me. 👍
The AppVeyor failure looks related to this change.
Maybe the test just needs to be adjusted. Need to look at the test, understand what it's doing, and decide if the change from this PR caused a bug, or if the test just needs to be a adjusted. |
src/nvim/ex_docmd.c
Outdated
if (!isPreview) { | ||
// For execution of a preview command we have to wait for a return | ||
// key, but we don't want the message for it pop out | ||
no_wait_return++; // don't wait for return until finished |
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.
but we don't want the message for it pop out
If we don't want to wait, why no_wait_return++
for !isPreview
?
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.
Ops, may be wrong msg, I think I was thinking some otherthing, I also change it
The quickbuild BSD failure looks related:
|
I correct em |
By the way why this error occurs, I didn't changed the code of that part, I even didn't touch the code for that |
Perhaps I should make the commit again and test if that error persists, and if persists, I will try by removing the test. |
f17729d
to
23ef787
Compare
Lets have a try on this |
Yes error occurs, this may be due to my change in src, I try what can I do, I am sure, that error didn't occur previously, some changes occur after my work This is surly now I think the fault of my code, it works for this case, for |
When entering a large string in substitute command when
set inccommand=nosplit
is enabled, the string wraps around the single line. This was due to the condition that in Preview mode, we need a kind of behaviour where the DOCMD_NOWAIT is not completely necessary because there is change in the size of the cmdlilne, but we don't need to wait for the return, so ++no_wait_return was not necessary.