aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Edmund Lazo <jan.lazo@mail.utoronto.ca>2020-12-26 03:38:54 -0500
committerGitHub <noreply@github.com>2020-12-26 03:38:54 -0500
commitc64cce906e7ed828d331e1786c985ff7aa734546 (patch)
tree5f8913cf05a046d2ec23840915d8bb1884db768f
parent84faeb07d0018c674c2bc730333fefae6123f366 (diff)
parent44bb7147e40743d9a70ee3a2663a7a7dacec7b13 (diff)
downloadrneovim-c64cce906e7ed828d331e1786c985ff7aa734546.tar.gz
rneovim-c64cce906e7ed828d331e1786c985ff7aa734546.tar.bz2
rneovim-c64cce906e7ed828d331e1786c985ff7aa734546.zip
Merge pull request #10848 from janlazo/vim-8.1.1189
vim-patch:8.1.{822,1189,1192}
-rw-r--r--src/nvim/edit.c2
-rw-r--r--src/nvim/ex_cmds.c9
-rw-r--r--src/nvim/ex_docmd.c4
-rw-r--r--src/nvim/ex_getln.c4
-rw-r--r--src/nvim/getchar.c6
-rw-r--r--src/nvim/globals.h5
-rw-r--r--src/nvim/main.c2
-rw-r--r--src/nvim/message.c30
-rw-r--r--src/nvim/screen.c37
-rw-r--r--src/nvim/spellfile.c2
-rw-r--r--src/nvim/testdir/test_bufline.vim2
-rw-r--r--src/nvim/testdir/test_messages.vim59
-rw-r--r--test/functional/eval/null_spec.lua2
-rw-r--r--test/functional/eval/timer_spec.lua4
-rw-r--r--test/functional/ui/float_spec.lua43
-rw-r--r--test/functional/ui/screen.lua4
-rw-r--r--test/functional/ui/searchhl_spec.lua11
17 files changed, 179 insertions, 47 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index ec424c12da..ebbb6e803a 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -7803,7 +7803,7 @@ static bool ins_esc(long *count, int cmdchar, bool nomove)
// Otherwise remove the mode message.
if (reg_recording != 0 || restart_edit != NUL) {
showmode();
- } else if (p_smd) {
+ } else if (p_smd && (got_int || !skip_showmode())) {
MSG("");
}
// Exit Insert mode
diff --git a/src/nvim/ex_cmds.c b/src/nvim/ex_cmds.c
index 2a96db6a8c..6e08378ad4 100644
--- a/src/nvim/ex_cmds.c
+++ b/src/nvim/ex_cmds.c
@@ -3712,8 +3712,9 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
redraw_later(curwin, SOME_VALID);
curwin->w_p_fen = save_p_fen;
- if (msg_row == Rows - 1)
- msg_didout = FALSE; /* avoid a scroll-up */
+ if (msg_row == Rows - 1) {
+ msg_didout = false; // avoid a scroll-up
+ }
msg_starthere();
i = msg_scroll;
msg_scroll = 0; /* truncate msg when
@@ -3732,8 +3733,8 @@ static buf_T *do_sub(exarg_T *eap, proftime_T timeout,
typed = plain_vgetc();
no_mapping--;
- /* clear the question */
- msg_didout = FALSE; /* don't scroll up */
+ // clear the question
+ msg_didout = false; // don't scroll up
msg_col = 0;
gotocmdline(TRUE);
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c
index 63e5c1c9ed..601f4aab38 100644
--- a/src/nvim/ex_docmd.c
+++ b/src/nvim/ex_docmd.c
@@ -8062,8 +8062,8 @@ static void ex_redraw(exarg_T *eap)
RedrawingDisabled = r;
p_lz = p;
- /* Reset msg_didout, so that a message that's there is overwritten. */
- msg_didout = FALSE;
+ // Reset msg_didout, so that a message that's there is overwritten.
+ msg_didout = false;
msg_col = 0;
/* No need to wait after an intentional redraw. */
diff --git a/src/nvim/ex_getln.c b/src/nvim/ex_getln.c
index 24fc60e60a..5e3cdd5da2 100644
--- a/src/nvim/ex_getln.c
+++ b/src/nvim/ex_getln.c
@@ -2740,8 +2740,8 @@ redraw:
no_mapping--;
- /* make following messages go to the next line */
- msg_didout = FALSE;
+ // make following messages go to the next line
+ msg_didout = false;
msg_col = 0;
if (msg_row < Rows - 1) {
msg_row++;
diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c
index 2e2993ed26..eddbdef739 100644
--- a/src/nvim/getchar.c
+++ b/src/nvim/getchar.c
@@ -2490,8 +2490,10 @@ int inchar(
}
// Always flush the output characters when getting input characters
- // from the user.
- ui_flush();
+ // from the user and not just peeking.
+ if (wait_time == -1L || wait_time > 10L) {
+ ui_flush();
+ }
// Fill up to a third of the buffer, because each character may be
// tripled below.
diff --git a/src/nvim/globals.h b/src/nvim/globals.h
index c53c1546a4..6b962dc1f6 100644
--- a/src/nvim/globals.h
+++ b/src/nvim/globals.h
@@ -139,8 +139,9 @@ EXTERN int mod_mask INIT(= 0x0); // current key modifiers
EXTERN int cmdline_row;
EXTERN int redraw_cmdline INIT(= false); // cmdline must be redrawn
+EXTERN bool redraw_mode INIT(= false); // mode must be redrawn
EXTERN int clear_cmdline INIT(= false); // cmdline must be cleared
-EXTERN int mode_displayed INIT(= false); // mode is being displayed
+EXTERN bool mode_displayed INIT(= false); // mode is being displayed
EXTERN int cmdline_star INIT(= false); // cmdline is crypted
EXTERN int redrawing_cmdline INIT(= false); // cmdline is being redrawn
EXTERN int cmdline_was_last_drawn INIT(= false); // cmdline was last drawn
@@ -199,7 +200,7 @@ EXTERN int keep_msg_attr INIT(= 0); // highlight attr for keep_msg
EXTERN int keep_msg_more INIT(= false); // keep_msg was set by msgmore()
EXTERN int need_fileinfo INIT(= false); // do fileinfo() after redraw
EXTERN int msg_scroll INIT(= false); // msg_start() will scroll
-EXTERN int msg_didout INIT(= false); // msg_outstr() was used in line
+EXTERN bool msg_didout INIT(= false); // msg_outstr() was used in line
EXTERN int msg_didany INIT(= false); // msg_outstr() was used at all
EXTERN int msg_nowait INIT(= false); // don't wait for this msg
EXTERN int emsg_off INIT(= 0); // don't display errors for now,
diff --git a/src/nvim/main.c b/src/nvim/main.c
index 8bf745966e..e068b2361c 100644
--- a/src/nvim/main.c
+++ b/src/nvim/main.c
@@ -2006,7 +2006,7 @@ static void version(void)
info_message = TRUE; // use mch_msg(), not mch_errmsg()
list_version();
msg_putchar('\n');
- msg_didout = FALSE;
+ msg_didout = false;
}
/// Prints help message for "nvim -h" or "nvim --help".
diff --git a/src/nvim/message.c b/src/nvim/message.c
index 02a7732f5c..530b930fed 100644
--- a/src/nvim/message.c
+++ b/src/nvim/message.c
@@ -1128,11 +1128,11 @@ void wait_return(int redraw)
if (p_more) {
if (c == 'b' || c == 'k' || c == 'u' || c == 'g'
|| c == K_UP || c == K_PAGEUP) {
- if (msg_scrolled > Rows)
- /* scroll back to show older messages */
+ if (msg_scrolled > Rows) {
+ // scroll back to show older messages
do_more_prompt(c);
- else {
- msg_didout = FALSE;
+ } else {
+ msg_didout = false;
c = K_IGNORE;
msg_col =
cmdmsg_rl ? Columns - 1 :
@@ -2097,15 +2097,17 @@ static void msg_puts_display(const char_u *str, int maxlen, int attr,
store_sb_text((char_u **)&sb_str, (char_u *)s, attr, &sb_col, true);
}
- if (*s == '\n') { /* go to next line */
- msg_didout = FALSE; /* remember that line is empty */
- if (cmdmsg_rl)
+ if (*s == '\n') { // go to next line
+ msg_didout = false; // remember that line is empty
+ if (cmdmsg_rl) {
msg_col = Columns - 1;
- else
+ } else {
msg_col = 0;
- if (++msg_row >= Rows) /* safety check */
+ }
+ if (++msg_row >= Rows) { // safety check
msg_row = Rows - 1;
- } else if (*s == '\r') { /* go to column 0 */
+ }
+ } else if (*s == '\r') { // go to column 0
msg_col = 0;
} else if (*s == '\b') { /* go to previous char */
if (msg_col)
@@ -2878,10 +2880,10 @@ void repeat_message(void)
ui_cursor_goto(msg_row, msg_col); /* put cursor back */
} else if (State == HITRETURN || State == SETWSIZE) {
if (msg_row == Rows - 1) {
- /* Avoid drawing the "hit-enter" prompt below the previous one,
- * overwrite it. Esp. useful when regaining focus and a
- * FocusGained autocmd exists but didn't draw anything. */
- msg_didout = FALSE;
+ // Avoid drawing the "hit-enter" prompt below the previous one,
+ // overwrite it. Esp. useful when regaining focus and a
+ // FocusGained autocmd exists but didn't draw anything.
+ msg_didout = false;
msg_col = 0;
msg_clr_eos();
}
diff --git a/src/nvim/screen.c b/src/nvim/screen.c
index afabbe6afc..07c959b257 100644
--- a/src/nvim/screen.c
+++ b/src/nvim/screen.c
@@ -620,7 +620,7 @@ int update_screen(int type)
/* Clear or redraw the command line. Done last, because scrolling may
* mess up the command line. */
- if (clear_cmdline || redraw_cmdline) {
+ if (clear_cmdline || redraw_cmdline || redraw_mode) {
showmode();
}
@@ -6557,12 +6557,28 @@ void grid_del_lines(ScreenGrid *grid, int row, int line_count, int end, int col,
return;
}
+// Return true when postponing displaying the mode message: when not redrawing
+// or inside a mapping.
+bool skip_showmode(void)
+{
+ // Call char_avail() only when we are going to show something, because it
+ // takes a bit of time. redrawing() may also call char_avail_avail().
+ if (global_busy
+ || msg_silent != 0
+ || !redrawing()
+ || (char_avail() && !KeyTyped)) {
+ redraw_mode = true; // show mode later
+ return true;
+ }
+ return false;
+}
// Show the current mode and ruler.
//
// If clear_cmdline is TRUE, clear the rest of the cmdline.
// If clear_cmdline is FALSE there may be a message there that needs to be
// cleared only if a mode is shown.
+// If redraw_mode is true show or clear the mode.
// Return the length of the message (0 if no message).
int showmode(void)
{
@@ -6588,12 +6604,8 @@ int showmode(void)
|| restart_edit
|| VIsual_active));
if (do_mode || reg_recording != 0) {
- // Don't show mode right now, when not redrawing or inside a mapping.
- // Call char_avail() only when we are going to show something, because
- // it takes a bit of time.
- if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0) {
- redraw_cmdline = TRUE; /* show mode later */
- return 0;
+ if (skip_showmode()) {
+ return 0; // show mode later
}
nwr_save = need_wait_return;
@@ -6713,10 +6725,11 @@ int showmode(void)
need_clear = true;
}
- mode_displayed = TRUE;
- if (need_clear || clear_cmdline)
+ mode_displayed = true;
+ if (need_clear || clear_cmdline || redraw_mode) {
msg_clr_eos();
- msg_didout = FALSE; /* overwrite this message */
+ }
+ msg_didout = false; // overwrite this message
length = msg_col;
msg_col = 0;
msg_no_more = false;
@@ -6725,6 +6738,9 @@ int showmode(void)
} else if (clear_cmdline && msg_silent == 0) {
// Clear the whole command line. Will reset "clear_cmdline".
msg_clr_cmdline();
+ } else if (redraw_mode) {
+ msg_pos_mode();
+ msg_clr_eos();
}
// NB: also handles clearing the showmode if it was emtpy or disabled
@@ -6741,6 +6757,7 @@ int showmode(void)
win_redr_ruler(last, true);
}
redraw_cmdline = false;
+ redraw_mode = false;
clear_cmdline = false;
return length;
diff --git a/src/nvim/spellfile.c b/src/nvim/spellfile.c
index 90af010164..90945eafd7 100644
--- a/src/nvim/spellfile.c
+++ b/src/nvim/spellfile.c
@@ -3942,7 +3942,7 @@ static int tree_add_word(spellinfo_T *spin, char_u *word, wordnode_T *root, int
msg_start();
msg_puts(_(msg_compressing));
msg_clr_eos();
- msg_didout = FALSE;
+ msg_didout = false;
msg_col = 0;
ui_flush();
}
diff --git a/src/nvim/testdir/test_bufline.vim b/src/nvim/testdir/test_bufline.vim
index 076f03fdd8..2567dd2be2 100644
--- a/src/nvim/testdir/test_bufline.vim
+++ b/src/nvim/testdir/test_bufline.vim
@@ -19,7 +19,7 @@ func Test_setbufline_getbufline()
let b = bufnr('%')
wincmd w
call assert_equal(1, setbufline(b, 5, ['x']))
- call assert_equal(1, setbufline(1234, 1, ['x']))
+ call assert_equal(1, setbufline(bufnr('$') + 1, 1, ['x']))
call assert_equal(0, setbufline(b, 4, ['d', 'e']))
call assert_equal(['c'], getbufline(b, 3))
call assert_equal(['d'], getbufline(b, 4))
diff --git a/src/nvim/testdir/test_messages.vim b/src/nvim/testdir/test_messages.vim
index 30239a90c2..d0a8f342c9 100644
--- a/src/nvim/testdir/test_messages.vim
+++ b/src/nvim/testdir/test_messages.vim
@@ -89,6 +89,65 @@ func Test_echoerr()
call test_ignore_error('RESET')
endfunc
+func Test_mode_message_at_leaving_insert_by_ctrl_c()
+ if !has('terminal') || has('gui_running')
+ return
+ endif
+
+ " Set custom statusline built by user-defined function.
+ let testfile = 'Xtest.vim'
+ call writefile([
+ \ 'func StatusLine() abort',
+ \ ' return ""',
+ \ 'endfunc',
+ \ 'set statusline=%!StatusLine()',
+ \ 'set laststatus=2',
+ \ ], testfile)
+
+ let rows = 10
+ let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
+ call term_wait(buf, 200)
+ call assert_equal('run', job_status(term_getjob(buf)))
+
+ call term_sendkeys(buf, "i")
+ call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))})
+ call term_sendkeys(buf, "\<C-C>")
+ call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
+
+ call term_sendkeys(buf, ":qall!\<CR>")
+ call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
+ exe buf . 'bwipe!'
+ call delete(testfile)
+endfunc
+
+func Test_mode_message_at_leaving_insert_with_esc_mapped()
+ if !has('terminal') || has('gui_running')
+ return
+ endif
+
+ " Set custom statusline built by user-defined function.
+ let testfile = 'Xtest.vim'
+ call writefile([
+ \ 'set laststatus=2',
+ \ 'inoremap <Esc> <Esc>00',
+ \ ], testfile)
+
+ let rows = 10
+ let buf = term_start([GetVimProg(), '--clean', '-S', testfile], {'term_rows': rows})
+ call term_wait(buf, 200)
+ call assert_equal('run', job_status(term_getjob(buf)))
+
+ call term_sendkeys(buf, "i")
+ call WaitForAssert({-> assert_match('^-- INSERT --\s*$', term_getline(buf, rows))})
+ call term_sendkeys(buf, "\<Esc>")
+ call WaitForAssert({-> assert_match('^\s*$', term_getline(buf, rows))})
+
+ call term_sendkeys(buf, ":qall!\<CR>")
+ call WaitForAssert({-> assert_equal('dead', job_status(term_getjob(buf)))})
+ exe buf . 'bwipe!'
+ call delete(testfile)
+endfunc
+
func Test_echospace()
set noruler noshowcmd laststatus=1
call assert_equal(&columns - 1, v:echospace)
diff --git a/test/functional/eval/null_spec.lua b/test/functional/eval/null_spec.lua
index fa8f7d873f..bef41e52d4 100644
--- a/test/functional/eval/null_spec.lua
+++ b/test/functional/eval/null_spec.lua
@@ -121,7 +121,7 @@ describe('NULL', function()
null_test('does not make Neovim crash when v:oldfiles gets assigned to that', ':let v:oldfiles = L|oldfiles', 0)
null_expr_test('does not make complete() crash or error out',
'execute(":normal i\\<C-r>=complete(1, L)[-1]\\n")',
- '', '\n', function()
+ 0, '', function()
eq({''}, curbufmeths.get_lines(0, -1, false))
end)
null_expr_test('is accepted by setmatches()', 'setmatches(L)', 0, 0)
diff --git a/test/functional/eval/timer_spec.lua b/test/functional/eval/timer_spec.lua
index 9ee0735e40..3f57568b8e 100644
--- a/test/functional/eval/timer_spec.lua
+++ b/test/functional/eval/timer_spec.lua
@@ -130,12 +130,12 @@ describe('timers', function()
nvim_async("command", "call timer_start("..load_adjust(100)..", 'AddItem', {'repeat': -1})")
screen:expect([[
- ITEM 1 |
+ ^ITEM 1 |
ITEM 2 |
{1:~ }|
{1:~ }|
{1:~ }|
- ^ |
+ |
]])
nvim_async("command", "let g:cont = 1")
diff --git a/test/functional/ui/float_spec.lua b/test/functional/ui/float_spec.lua
index 32f9ae030f..8d654f6e5b 100644
--- a/test/functional/ui/float_spec.lua
+++ b/test/functional/ui/float_spec.lua
@@ -5344,6 +5344,45 @@ describe('floatwin', function()
-- at least. Also check invisible EndOfBuffer region blends correctly.
meths.buf_set_lines(buf, 0, -1, true, {" x x x xx", " x x x x"})
win = meths.open_win(buf, false, {relative='editor', width=12, height=3, row=0, col=11, style='minimal'})
+ if multigrid then
+ screen:expect{grid=[[
+ ## grid 1
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [2:----------------------------------------]|
+ [3:----------------------------------------]|
+ ## grid 2
+ # TODO: 测试字典信息的准确性 |
+ # FIXME: 测试字典信息的准确^性 |
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ ## grid 3
+ |
+ ## grid 6
+ {1: x x x xx}|
+ {1: x x x x}|
+ {1: }|
+ ]], float_pos={
+ [6] = { {
+ id = 1003
+ }, "NW", 1, 0, 11, true }
+ }}
+ else
+ screen:expect{grid=[[
+ # TODO: 测 {1: x x x xx} 确性 |
+ # FIXME: 测{1: x x x x}准确^性 |
+ {0:~ }{1: }{0: }|
+ {0:~ }|
+ {0:~ }|
+ {0:~ }|
+ |
+ ]]}
+ end
meths.win_set_option(win, 'winblend', 30)
screen:set_default_attr_ids({
[1] = {foreground = tonumber('0xb282b2'), background = tonumber('0xffcfff')},
@@ -5381,7 +5420,7 @@ describe('floatwin', function()
}, "NW", 1, 0, 11, true }
}}
else
- screen:expect([[
+ screen:expect{grid=[[
# TODO: 测 {2: x x x}{1:息}{2: xx} 确性 |
# FIXME: 测{1:试}{2:x x x}{1:息}{2: x}准确^性 |
{3:~ }{4: }{3: }|
@@ -5389,7 +5428,7 @@ describe('floatwin', function()
{3:~ }|
{3:~ }|
|
- ]])
+ ]]}
end
meths.win_set_config(win, {relative='editor', row=0, col=12})
diff --git a/test/functional/ui/screen.lua b/test/functional/ui/screen.lua
index 8fa9fcc42f..5104c58796 100644
--- a/test/functional/ui/screen.lua
+++ b/test/functional/ui/screen.lua
@@ -807,7 +807,9 @@ function Screen:_handle_mouse_off()
end
function Screen:_handle_mode_change(mode, idx)
- assert(mode == self._mode_info[idx+1].name)
+ if self._mode_info ~= nil then
+ assert(mode == self._mode_info[idx+1].name)
+ end
self.mode = mode
end
diff --git a/test/functional/ui/searchhl_spec.lua b/test/functional/ui/searchhl_spec.lua
index 222275eb4d..885fe7d4c9 100644
--- a/test/functional/ui/searchhl_spec.lua
+++ b/test/functional/ui/searchhl_spec.lua
@@ -20,6 +20,7 @@ describe('search highlighting', function()
[2] = {background = colors.Yellow}, -- Search
[3] = {reverse = true},
[4] = {foreground = colors.Red}, -- Message
+ [5] = {bold = true, reverse = true},
})
end)
@@ -159,7 +160,15 @@ describe('search highlighting', function()
]])
feed('/foo')
helpers.poke_eventloop()
- screen:expect_unchanged()
+ screen:expect{grid=[[
+ {3:foo} bar baz {3:│} |
+ bar baz {2:foo} {3:│} |
+ bar {2:foo} baz {3:│} |
+ {3:│} |
+ {1:~ }{3:│} |
+ {5:[No Name] [+] }{3:term }|
+ /foo^ |
+ ]]}
end)
it('works with incsearch', function()