Skip to content
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

Timer causes error on exit from Ex-mode #2079

Closed
markonm opened this issue Sep 11, 2017 · 2 comments
Closed

Timer causes error on exit from Ex-mode #2079

markonm opened this issue Sep 11, 2017 · 2 comments

Comments

@markonm
Copy link

markonm commented Sep 11, 2017

Version: 8.0.1067
Reproducible on gVim and Vim on Windows and Linux.

Steps to reproduce:

  1. vim --clean -S test.vim
  2. enter Ex-mode with Q
  3. exit Ex-mode with vi
  4. Vim throws an error E749: empty buffer

If there were some text in the buffer before entering Ex-mode, Vim throws E501: At end-of-file.
Interestingly, I we remove blank line from g:Foo there will be no errors. Same errors are also reproducible with gQ.

" test.vim
func! g:Foo(...)

endfunc
call timer_start(40,function('g:Foo'),{'repeat':-1})
unmap Q
@chrisbra
Copy link
Member

Looks like one needs to reset ex_pressedreturn

Can you check, if this patch fixes it:

diff --git a/src/ex_cmds2.c b/src/ex_cmds2.c
index 18930a6cf..bcb03a1bc 100644
--- a/src/ex_cmds2.c
+++ b/src/ex_cmds2.c
@@ -1223,6 +1223,7 @@ check_due_timer(void)
            int called_emsg_save = called_emsg;
            int did_throw_save = did_throw;
            int save_must_redraw = must_redraw;
+           int save_ex_pressedreturn = get_pressedreturn();

            timer_busy = timer_busy > 0 || vgetc_busy > 0;
            vgetc_busy = 0;
@@ -1247,6 +1248,7 @@ check_due_timer(void)
                need_update_screen = TRUE;
            must_redraw = must_redraw > save_must_redraw
                                              ? must_redraw : save_must_redraw;
+           set_pressedreturn(save_ex_pressedreturn);

            /* Only fire the timer again if it repeats and stop_timer() wasn't
             * called while inside the callback (tr_id == -1). */
diff --git a/src/ex_docmd.c b/src/ex_docmd.c
index 0bcb7fec5..e14105250 100644
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -12395,3 +12395,15 @@ ex_folddo(exarg_T *eap)
 #endif
 }
 #endif
+
+    int
+get_pressedreturn()
+{
+    return ex_pressedreturn;
+}
+
+    void
+set_pressedreturn(int val)
+{
+     ex_pressedreturn = val;
+}
diff --git a/src/proto/ex_docmd.pro b/src/proto/ex_docmd.pro
index 1a931e539..116ff4e72 100644
--- a/src/proto/ex_docmd.pro
+++ b/src/proto/ex_docmd.pro
@@ -63,4 +63,6 @@ void dialog_msg(char_u *buff, char *format, char_u *fname);
 char_u *get_behave_arg(expand_T *xp, int idx);
 char_u *get_messages_arg(expand_T *xp, int idx);
 char_u *get_mapclear_arg(expand_T *xp, int idx);
+int get_pressedreturn(void);
+void set_pressedreturn(int val);
 /* vim: set ft=c : */

@markonm
Copy link
Author

markonm commented Sep 11, 2017

It fixed the issue. Thank you!

adizero pushed a commit to adizero/vim that referenced this issue May 19, 2018
Problem:    Timer causes error on exit from Ex mode. (xtal8)
Solution:   save and restore the ex_pressedreturn flag. (Christian Brabandt,
            closes vim#2079)
blueyed added a commit to blueyed/neovim that referenced this issue Jun 17, 2019
Problem:    Timer causes error on exit from Ex mode. (xtal8)
Solution:   save and restore the ex_pressedreturn flag. (Christian Brabandt,
            closes vim/vim#2079)
vim/vim@f5291f3
afnanenayet added a commit to afnanenayet/neovim that referenced this issue Sep 15, 2019
Problem:    Timer causes error on exit from Ex mode. (xtal8)
Solution:   save and restore the ex_pressedreturn flag. (Christian Brabandt,
            closes vim/vim#2079)
vim/vim@f5291f3
janlazo added a commit to janlazo/neovim that referenced this issue Sep 20, 2019
Problem:    Timer causes error on exit from Ex mode. (xtal8)
Solution:   save and restore the ex_pressedreturn flag. (Christian Brabandt,
            closes vim/vim#2079)
vim/vim@f5291f3
janlazo added a commit to janlazo/neovim that referenced this issue Sep 21, 2019
Problem:    Timer causes error on exit from Ex mode. (xtal8)
Solution:   save and restore the ex_pressedreturn flag. (Christian Brabandt,
            closes vim/vim#2079)
vim/vim@f5291f3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants