mirror of
https://github.com/neovim/neovim.git
synced 2024-12-24 13:15:09 -07:00
commit
5134b22ac5
@ -1408,8 +1408,10 @@ int op_delete(oparg_T *oap)
|
||||
free_register(&y_regs[9]); /* free register "9 */
|
||||
for (n = 9; n > 1; n--)
|
||||
y_regs[n] = y_regs[n - 1];
|
||||
y_previous = &y_regs[1];
|
||||
y_regs[1].y_array = NULL; /* set register "1 to empty */
|
||||
if (!is_append_register(oap->regname)) {
|
||||
y_previous = &y_regs[1];
|
||||
}
|
||||
y_regs[1].y_array = NULL; // set register "1 to empty
|
||||
reg = &y_regs[1];
|
||||
op_yank_reg(oap, false, reg, false);
|
||||
}
|
||||
@ -2789,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;
|
||||
}
|
||||
|
@ -1,3 +1,4 @@
|
||||
" Tests for put commands, e.g. ":put", "p", "gp", "P", "gP", etc.
|
||||
|
||||
func Test_put_block()
|
||||
if !has('multi_byte')
|
||||
@ -47,3 +48,59 @@ func Test_put_expr()
|
||||
call assert_equal(['A1','A2','A3','4A','5A','6A'], getline(1,'$'))
|
||||
bw!
|
||||
endfunc
|
||||
|
||||
func Test_put_lines()
|
||||
new
|
||||
let a = [ getreg('a'), getregtype('a') ]
|
||||
call setline(1, ['Line 1', 'Line2', 'Line 3', ''])
|
||||
exe 'norm! gg"add"AddG""p'
|
||||
call assert_equal(['Line 3', '', 'Line 1', 'Line2'], getline(1,'$'))
|
||||
" clean up
|
||||
bw!
|
||||
call setreg('a', a[0], a[1])
|
||||
endfunc
|
||||
|
||||
func Test_put_fails_when_nomodifiable()
|
||||
new
|
||||
setlocal 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
|
||||
setlocal 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
|
||||
|
@ -134,6 +134,8 @@ func Test_non_zero_arg()
|
||||
" call test_settime(93784)
|
||||
" call Try_arg_non_zero("mode(%v%)", 'x', 'x!')
|
||||
" call test_settime(0)
|
||||
let shellslash = &shellslash
|
||||
set shellslash
|
||||
|
||||
call Try_arg_non_zero("shellescape('foo%', %v%)", "'foo%'", "'foo\\%'")
|
||||
|
||||
@ -152,4 +154,6 @@ func Test_non_zero_arg()
|
||||
let r = visualmode(v)
|
||||
call assert_equal('', r, 'result for ' . v . ' is not "" but ' . r)
|
||||
endfor
|
||||
|
||||
let &shellslash = shellslash
|
||||
endfunc
|
||||
|
Loading…
Reference in New Issue
Block a user