From 24ab81bd46b217918be1992585e1fffa2e5617ea Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Wed, 1 Apr 2020 21:44:46 -0400 Subject: [PATCH 1/5] fixup! vim-patch:8.0.0858: check if job terminal is running #10908 --- src/nvim/ex_cmds2.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index 6b03117ff3..dfbbe2e1ac 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1503,8 +1503,10 @@ bool check_changed_any(bool hidden, bool unload) msg_col = 0; msg_didout = false; } - if (EMSG2(_("E162: No write since last change for buffer \"%s\""), - buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname)) { + if ((buf->terminal && channel_job_running((uint64_t)buf->b_p_channel)) + ? EMSG2(_("E947: Job still running in buffer \"%s\""), buf->b_fname) + : EMSG2(_("E162: No write since last change for buffer \"%s\""), + buf_spname(buf) != NULL ? buf_spname(buf) : buf->b_fname)) { save = no_wait_return; no_wait_return = false; wait_return(false); From 11249ad0216c6dac1ba20558038d0fb75add0495 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 10 Mar 2020 21:42:50 -0400 Subject: [PATCH 2/5] vim-patch:8.0.0953: get "no write since last change" error in terminal window Problem: Get "no write since last change" error in terminal window. Solution: Use another message when closing a terminal window. Make ":quit!" also end the job. https://github.com/vim/vim/commit/f5be7cd01642fafc4b7d68894eb60cca60c7a405 --- src/nvim/buffer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index ffa44c33cd..a46784fdb6 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1637,12 +1637,22 @@ void do_autochdir(void) void no_write_message(void) { - EMSG(_("E37: No write since last change (add ! to override)")); + if (curbuf->terminal + && channel_job_running((uint64_t)curbuf->b_p_channel)) { + EMSG(_("E948: Job still running (add ! to end the job)")); + } else { + EMSG(_("E37: No write since last change (add ! to override)")); + } } void no_write_message_nobang(void) { - EMSG(_("E37: No write since last change")); + if (curbuf->terminal + && channel_job_running((uint64_t)curbuf->b_p_channel)) { + EMSG(_("E948: Job still running")); + } else { + EMSG(_("E37: No write since last change")); + } } // From 56f5e3bd6b9ea522f8099eb6f602490144f3c64a Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 10 Mar 2020 20:59:13 -0400 Subject: [PATCH 3/5] vim-patch:8.0.1525: using :wqa exits even if a job runs in a terminal window Problem: Using :wqa exits even if a job runs in a terminal window. (Jason Felice) Solution: Check if a terminal has a running job. (closes vim/vim#2654) https://github.com/vim/vim/commit/7a76092a51fc5446426a4bfd9eb6503ec61bf9e9 --- src/nvim/buffer.c | 7 ++++--- src/nvim/ex_cmds.c | 7 ++++++- src/nvim/ex_cmds2.c | 2 +- test/functional/terminal/buffer_spec.lua | 5 +++++ 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/nvim/buffer.c b/src/nvim/buffer.c index a46784fdb6..839d61cd2e 100644 --- a/src/nvim/buffer.c +++ b/src/nvim/buffer.c @@ -1645,10 +1645,11 @@ void no_write_message(void) } } -void no_write_message_nobang(void) +void no_write_message_nobang(const buf_T *const buf) + FUNC_ATTR_NONNULL_ALL { - if (curbuf->terminal - && channel_job_running((uint64_t)curbuf->b_p_channel)) { + if (buf->terminal + && channel_job_running((uint64_t)buf->b_p_channel)) { EMSG(_("E948: Job still running")); } else { EMSG(_("E37: No write since last change")); diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c index d2ccbe3e6d..b0a51eaefd 100644 --- a/src/nvim/ex_cmds.c +++ b/src/nvim/ex_cmds.c @@ -1965,7 +1965,12 @@ void do_wqall(exarg_T *eap) } FOR_ALL_BUFFERS(buf) { - if (!bufIsChanged(buf) || bt_dontwrite(buf)) { + if (exiting + && buf->terminal + && channel_job_running((uint64_t)buf->b_p_channel)) { + no_write_message_nobang(buf); + error++; + } else if (!bufIsChanged(buf) || bt_dontwrite(buf)) { continue; } /* diff --git a/src/nvim/ex_cmds2.c b/src/nvim/ex_cmds2.c index dfbbe2e1ac..3b9c44c3cd 100644 --- a/src/nvim/ex_cmds2.c +++ b/src/nvim/ex_cmds2.c @@ -1297,7 +1297,7 @@ bool check_changed(buf_T *buf, int flags) if (flags & CCGD_EXCMD) { no_write_message(); } else { - no_write_message_nobang(); + no_write_message_nobang(curbuf); } return true; } diff --git a/test/functional/terminal/buffer_spec.lua b/test/functional/terminal/buffer_spec.lua index 8e171d31aa..209537831f 100644 --- a/test/functional/terminal/buffer_spec.lua +++ b/test/functional/terminal/buffer_spec.lua @@ -6,6 +6,7 @@ local eval, feed_command, source = helpers.eval, helpers.feed_command, helpers.s local eq, neq = helpers.eq, helpers.neq local write_file = helpers.write_file local command= helpers.command +local exc_exec = helpers.exc_exec describe(':terminal buffer', function() local screen @@ -253,6 +254,10 @@ describe(':terminal buffer', function() ]]) command('bdelete!') end) + + it('handles wqall', function() + eq('Vim(wqall):E948: Job still running', exc_exec('wqall')) + end) end) describe('No heap-buffer-overflow when using', function() From 4b74996dbcf7ba6b10b375fa75c796630b8d5b50 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 1 Dec 2020 01:59:28 -0500 Subject: [PATCH 4/5] test/timer_spec: increase base timeout The following keeps happening in my local environment because the timeout is too short. [ FAILED ] test/functional/eval/timer_spec.lua @ 208: timers do not crash when processing events in the handler test/functional/eval/timer_spec.lua:219: retry() attempts: 1 test/helpers.lua:73: Expected objects to be the same. Passed in: (number) 0 Expected: (number) 1 --- test/functional/eval/timer_spec.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua index ef7df69fdb..9ee0735e40 100644 --- a/test/functional/eval/timer_spec.lua +++ b/test/functional/eval/timer_spec.lua @@ -215,8 +215,8 @@ describe('timers', function() endfunc ]]) command("call timer_start(5, 'MyHandler', {'repeat': 1})") - run(nil, nil, nil, load_adjust(10)) - retry(nil, load_adjust(100), function() + run(nil, nil, nil, load_adjust(20)) + retry(nil, load_adjust(150), function() eq(1, eval("g:val")) end) end) From 518fe0e8a2de00ce6b7f62183dfa89b410378a89 Mon Sep 17 00:00:00 2001 From: Jan Edmund Lazo Date: Tue, 1 Dec 2020 02:10:09 -0500 Subject: [PATCH 5/5] test/wildmode_spec: override $PS1 User config may set $PS1 for a colored prompt. It breaks the screen tests. --- test/functional/terminal/scrollback_spec.lua | 1 + test/functional/ui/wildmode_spec.lua | 1 + 2 files changed, 2 insertions(+) diff --git a/test/functional/terminal/scrollback_spec.lua b/test/functional/terminal/scrollback_spec.lua index 77fdba7fc4..b932c58430 100644 --- a/test/functional/terminal/scrollback_spec.lua +++ b/test/functional/terminal/scrollback_spec.lua @@ -410,6 +410,7 @@ describe("'scrollback' option", function() command([[let $PROMPT='$$']]) screen = thelpers.screen_setup(nil, "['cmd.exe']", 30) else + command('let $PS1 = "$"') screen = thelpers.screen_setup(nil, "['sh']", 30) end diff --git a/test/functional/ui/wildmode_spec.lua b/test/functional/ui/wildmode_spec.lua index 99ebc4971e..6e736b2534 100644 --- a/test/functional/ui/wildmode_spec.lua +++ b/test/functional/ui/wildmode_spec.lua @@ -160,6 +160,7 @@ describe("'wildmenu'", function() if not iswin() then command('set shell=sh') -- Need a predictable "$" prompt. + command('let $PS1 = "$"') end command('set laststatus=0') command('vsplit')