diff options
author | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-04-01 21:46:16 -0400 |
---|---|---|
committer | Jan Edmund Lazo <jan.lazo@mail.utoronto.ca> | 2019-04-01 21:48:01 -0400 |
commit | 773086388d3d03a288f4b9407a467223011e5347 (patch) | |
tree | cc918cb0af2fbca84d22872488812d5d444b0f4a /src | |
parent | 8843928e10512b5ce17a99d896a16f03c12aeba1 (diff) | |
download | rneovim-773086388d3d03a288f4b9407a467223011e5347.tar.gz rneovim-773086388d3d03a288f4b9407a467223011e5347.tar.bz2 rneovim-773086388d3d03a288f4b9407a467223011e5347.zip |
vim-patch:8.1.0118: duplicate error message for put command
Problem: Duplicate error message for put command.
Solution: Check return value of u_save(). (Jason Franklin)
https://github.com/vim/vim/commit/f52f9ea8f5fb3df51a308c56f2bf66f735ef3ca7
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/ops.c | 4 | ||||
-rw-r--r-- | src/nvim/testdir/test_put.vim | 46 |
2 files changed, 48 insertions, 2 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c index f4db97670e..0b604fa4ba 100644 --- a/src/nvim/ops.c +++ b/src/nvim/ops.c @@ -2791,8 +2791,8 @@ void do_put(int regname, yankreg_T *reg, int dir, long count, int flags) } if (!curbuf->terminal) { - // Autocommands may be executed when saving lines for undo, which may make - // y_array invalid. Start undo now to avoid that. + // Autocommands may be executed when saving lines for undo. This might + // make y_array invalid, so we start undo now to avoid that. if (u_save(curwin->w_cursor.lnum, curwin->w_cursor.lnum + 1) == FAIL) { return; } diff --git a/src/nvim/testdir/test_put.vim b/src/nvim/testdir/test_put.vim index b95406c5a7..6a7b2b2d93 100644 --- a/src/nvim/testdir/test_put.vim +++ b/src/nvim/testdir/test_put.vim @@ -1,3 +1,4 @@ +" Tests for put commands, e.g. ":put", "p", "gp", "P", "gP", etc. func Test_put_block() if !has('multi_byte') @@ -58,3 +59,48 @@ func Test_put_lines() bw! call setreg('a', a[0], a[1]) endfunc + +func Test_put_fails_when_nomodifiable() + new + set nomodifiable + + normal! yy + call assert_fails(':put', 'E21') + call assert_fails(':put!', 'E21') + call assert_fails(':normal! p', 'E21') + call assert_fails(':normal! gp', 'E21') + call assert_fails(':normal! P', 'E21') + call assert_fails(':normal! gP', 'E21') + + if has('mouse') + set mouse=n + call assert_fails('execute "normal! \<MiddleMouse>"', 'E21') + set mouse& + endif + + bwipeout! +endfunc + +" A bug was discovered where the Normal mode put commands (e.g., "p") would +" output duplicate error messages when invoked in a non-modifiable buffer. +func Test_put_p_errmsg_nodup() + new + set nomodifiable + + normal! yy + + func Capture_p_error() + redir => s:p_err + normal! p + redir END + endfunc + + silent! call Capture_p_error() + + " Error message output within a function should be three lines (the function + " name, the line number, and the error message). + call assert_equal(3, count(s:p_err, "\n")) + + delfunction Capture_p_error + bwipeout! +endfunc |