mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Merge pull request #13375 from janlazo/vim-8.2.2041
vim-patch:8.1.{2290,2390},8.2.{242,257,302,303,462,991,996,2041,2042,2043,2047,2048,2049,2054}
This commit is contained in:
commit
4537ff659e
@ -2487,6 +2487,7 @@ wait({timeout}, {condition}[, {interval}])
|
|||||||
wildmenumode() Number whether 'wildmenu' mode is active
|
wildmenumode() Number whether 'wildmenu' mode is active
|
||||||
win_findbuf({bufnr}) List find windows containing {bufnr}
|
win_findbuf({bufnr}) List find windows containing {bufnr}
|
||||||
win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab}
|
win_getid([{win} [, {tab}]]) Number get |window-ID| for {win} in {tab}
|
||||||
|
win_gettype([{nr}]) String type of window {nr}
|
||||||
win_gotoid({expr}) Number go to |window-ID| {expr}
|
win_gotoid({expr}) Number go to |window-ID| {expr}
|
||||||
win_id2tabwin({expr}) List get tab and window nr from |window-ID|
|
win_id2tabwin({expr}) List get tab and window nr from |window-ID|
|
||||||
win_id2win({expr}) Number get window nr from |window-ID|
|
win_id2win({expr}) Number get window nr from |window-ID|
|
||||||
@ -9277,6 +9278,24 @@ win_getid([{win} [, {tab}]]) *win_getid()*
|
|||||||
number {tab}. The first tab has number one.
|
number {tab}. The first tab has number one.
|
||||||
Return zero if the window cannot be found.
|
Return zero if the window cannot be found.
|
||||||
|
|
||||||
|
win_gettype([{nr}]) *win_gettype()*
|
||||||
|
Return the type of the window:
|
||||||
|
"autocmd" autocommand window. Temporary window
|
||||||
|
used to execute autocommands.
|
||||||
|
"popup" popup window |popup|
|
||||||
|
"preview" preview window |preview-window|
|
||||||
|
"command" command-line window |cmdwin|
|
||||||
|
(empty) normal window
|
||||||
|
"unknown" window {nr} not found
|
||||||
|
|
||||||
|
When {nr} is omitted return the type of the current window.
|
||||||
|
When {nr} is given return the type of this window by number or
|
||||||
|
|window-ID|.
|
||||||
|
|
||||||
|
Also see the 'buftype' option. When running a terminal in a
|
||||||
|
popup window then 'buftype' is "terminal" and win_gettype()
|
||||||
|
returns "popup".
|
||||||
|
|
||||||
win_gotoid({expr}) *win_gotoid()*
|
win_gotoid({expr}) *win_gotoid()*
|
||||||
Go to window with ID {expr}. This may also change the current
|
Go to window with ID {expr}. This may also change the current
|
||||||
tabpage.
|
tabpage.
|
||||||
|
@ -693,15 +693,9 @@ au BufNewFile,BufRead *.haml setf haml
|
|||||||
|
|
||||||
" Hamster Classic | Playground files
|
" Hamster Classic | Playground files
|
||||||
au BufNewFile,BufRead *.hsm setf hamster
|
au BufNewFile,BufRead *.hsm setf hamster
|
||||||
au BufNewFile,BufRead *.hsc
|
|
||||||
\ if match(join(getline(1,10), "\n"), '\%(^\|\n\)\s*\%({-#\_s*LANGUAGE\>\|\<module\>\)') != -1 |
|
|
||||||
\ setf haskell |
|
|
||||||
\ else |
|
|
||||||
\ setf hamster |
|
|
||||||
\ endif
|
|
||||||
|
|
||||||
" Haskell
|
" Haskell
|
||||||
au BufNewFile,BufRead *.hs,*.hs-boot setf haskell
|
au BufNewFile,BufRead *.hs,*.hsc,*.hs-boot setf haskell
|
||||||
au BufNewFile,BufRead *.lhs setf lhaskell
|
au BufNewFile,BufRead *.lhs setf lhaskell
|
||||||
au BufNewFile,BufRead *.chs setf chaskell
|
au BufNewFile,BufRead *.chs setf chaskell
|
||||||
au BufNewFile,BufRead cabal.project setf cabalproject
|
au BufNewFile,BufRead cabal.project setf cabalproject
|
||||||
|
@ -385,6 +385,7 @@ return {
|
|||||||
wildmenumode={},
|
wildmenumode={},
|
||||||
win_findbuf={args=1},
|
win_findbuf={args=1},
|
||||||
win_getid={args={0,2}},
|
win_getid={args={0,2}},
|
||||||
|
win_gettype={args={0,1}},
|
||||||
win_gotoid={args=1},
|
win_gotoid={args=1},
|
||||||
win_id2tabwin={args=1},
|
win_id2tabwin={args=1},
|
||||||
win_id2win={args=1},
|
win_id2win={args=1},
|
||||||
|
@ -10992,6 +10992,31 @@ static void f_win_getid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
|||||||
rettv->vval.v_number = win_getid(argvars);
|
rettv->vval.v_number = win_getid(argvars);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// "win_gettype(nr)" function
|
||||||
|
static void f_win_gettype(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
|
{
|
||||||
|
win_T *wp = curwin;
|
||||||
|
|
||||||
|
rettv->v_type = VAR_STRING;
|
||||||
|
rettv->vval.v_string = NULL;
|
||||||
|
if (argvars[0].v_type != VAR_UNKNOWN) {
|
||||||
|
wp = find_win_by_nr_or_id(&argvars[0]);
|
||||||
|
if (wp == NULL) {
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)"unknown");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (wp == aucmd_win) {
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)"autocmd");
|
||||||
|
} else if (wp->w_p_pvw) {
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)"preview");
|
||||||
|
} else if (wp->w_floating) {
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)"popup");
|
||||||
|
} else if (wp == curwin && cmdwin_type != 0) {
|
||||||
|
rettv->vval.v_string = vim_strsave((char_u *)"command");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// "win_gotoid()" function
|
/// "win_gotoid()" function
|
||||||
static void f_win_gotoid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
static void f_win_gotoid(typval_T *argvars, typval_T *rettv, FunPtr fptr)
|
||||||
{
|
{
|
||||||
|
@ -696,6 +696,7 @@ func Test_OptionSet_diffmode_close()
|
|||||||
call setline(1, ['buffer 2', 'line 2', 'line 3', 'line4'])
|
call setline(1, ['buffer 2', 'line 2', 'line 3', 'line4'])
|
||||||
call assert_fails(':diffthis', 'E788')
|
call assert_fails(':diffthis', 'E788')
|
||||||
call assert_equal(1, &diff)
|
call assert_equal(1, &diff)
|
||||||
|
set diffopt-=closeoff
|
||||||
bw!
|
bw!
|
||||||
call assert_fails(':diffoff!', 'E788')
|
call assert_fails(':diffoff!', 'E788')
|
||||||
bw!
|
bw!
|
||||||
@ -1856,6 +1857,29 @@ func Test_FileChangedShell_reload()
|
|||||||
call delete('Xchanged')
|
call delete('Xchanged')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func LogACmd()
|
||||||
|
call add(g:logged, line('$'))
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_TermChanged()
|
||||||
|
throw 'skipped: Nvim does not support TermChanged event'
|
||||||
|
CheckNotGui
|
||||||
|
|
||||||
|
enew!
|
||||||
|
tabnew
|
||||||
|
call setline(1, ['a', 'b', 'c', 'd'])
|
||||||
|
$
|
||||||
|
au TermChanged * call LogACmd()
|
||||||
|
let g:logged = []
|
||||||
|
let term_save = &term
|
||||||
|
set term=xterm
|
||||||
|
call assert_equal([1, 4], g:logged)
|
||||||
|
|
||||||
|
au! TermChanged
|
||||||
|
let &term = term_save
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" Test for FileReadCmd autocmd
|
" Test for FileReadCmd autocmd
|
||||||
func Test_autocmd_FileReadCmd()
|
func Test_autocmd_FileReadCmd()
|
||||||
func ReadFileCmd()
|
func ReadFileCmd()
|
||||||
@ -1910,4 +1934,26 @@ func Test_autocmd_sigusr1()
|
|||||||
unlet g:sigusr1_passed
|
unlet g:sigusr1_passed
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Test for the temporary internal window used to execute autocmds
|
||||||
|
func Test_autocmd_window()
|
||||||
|
%bw!
|
||||||
|
edit one.txt
|
||||||
|
tabnew two.txt
|
||||||
|
let g:blist = []
|
||||||
|
augroup aucmd_win_test
|
||||||
|
au!
|
||||||
|
au BufEnter * call add(g:blist, [expand('<afile>'),
|
||||||
|
\ win_gettype(bufwinnr(expand('<afile>')))])
|
||||||
|
augroup END
|
||||||
|
|
||||||
|
doautoall BufEnter
|
||||||
|
call assert_equal([['one.txt', 'autocmd'], ['two.txt', '']], g:blist)
|
||||||
|
|
||||||
|
augroup aucmd_win_test
|
||||||
|
au!
|
||||||
|
augroup END
|
||||||
|
augroup! aucmd_win_test
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -796,6 +796,29 @@ func Test_cmdwin_feedkeys()
|
|||||||
call feedkeys("q:\<CR>", 'x')
|
call feedkeys("q:\<CR>", 'x')
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Tests for the issues fixed in 7.4.441.
|
||||||
|
" When 'cedit' is set to Ctrl-C, opening the command window hangs Vim
|
||||||
|
func Test_cmdwin_cedit()
|
||||||
|
exe "set cedit=\<C-c>"
|
||||||
|
normal! :
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
|
||||||
|
let g:cmd_wintype = ''
|
||||||
|
func CmdWinType()
|
||||||
|
let g:cmd_wintype = getcmdwintype()
|
||||||
|
let g:wintype = win_gettype()
|
||||||
|
return ''
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
call feedkeys("\<C-c>a\<C-R>=CmdWinType()\<CR>\<CR>")
|
||||||
|
echo input('')
|
||||||
|
call assert_equal('@', g:cmd_wintype)
|
||||||
|
call assert_equal('command', g:wintype)
|
||||||
|
|
||||||
|
set cedit&vim
|
||||||
|
delfunc CmdWinType
|
||||||
|
endfunc
|
||||||
|
|
||||||
func Test_buffers_lastused()
|
func Test_buffers_lastused()
|
||||||
" check that buffers are sorted by time when wildmode has lastused
|
" check that buffers are sorted by time when wildmode has lastused
|
||||||
edit bufc " oldest
|
edit bufc " oldest
|
||||||
|
@ -200,8 +200,8 @@ let s:filename_checks = {
|
|||||||
\ 'gsp': ['file.gsp'],
|
\ 'gsp': ['file.gsp'],
|
||||||
\ 'gtkrc': ['.gtkrc', 'gtkrc'],
|
\ 'gtkrc': ['.gtkrc', 'gtkrc'],
|
||||||
\ 'haml': ['file.haml'],
|
\ 'haml': ['file.haml'],
|
||||||
\ 'hamster': ['file.hsc', 'file.hsm'],
|
\ 'hamster': ['file.hsm'],
|
||||||
\ 'haskell': ['file.hs', 'file.hs-boot'],
|
\ 'haskell': ['file.hs', 'file.hsc', 'file.hs-boot'],
|
||||||
\ 'haste': ['file.ht'],
|
\ 'haste': ['file.ht'],
|
||||||
\ 'hastepreproc': ['file.htpp'],
|
\ 'hastepreproc': ['file.htpp'],
|
||||||
\ 'hb': ['file.hb'],
|
\ 'hb': ['file.hb'],
|
||||||
|
@ -735,20 +735,25 @@ func Test_popup_and_preview_autocommand()
|
|||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_popup_and_previewwindow_dump()
|
func Test_popup_and_previewwindow_dump()
|
||||||
if !CanRunVimInTerminal()
|
CheckScreendump
|
||||||
return
|
CheckFeature quickfix
|
||||||
endif
|
|
||||||
call writefile([
|
let lines =<< trim END
|
||||||
\ 'set previewheight=9',
|
set previewheight=9
|
||||||
\ 'silent! pedit',
|
silent! pedit
|
||||||
\ 'call setline(1, map(repeat(["ab"], 10), "v:val. v:key"))',
|
call setline(1, map(repeat(["ab"], 10), "v:val .. v:key"))
|
||||||
\ 'exec "norm! G\<C-E>\<C-E>"',
|
exec "norm! G\<C-E>\<C-E>"
|
||||||
\ ], 'Xscript')
|
END
|
||||||
|
call writefile(lines, 'Xscript')
|
||||||
let buf = RunVimInTerminal('-S Xscript', {})
|
let buf = RunVimInTerminal('-S Xscript', {})
|
||||||
|
|
||||||
|
" wait for the script to finish
|
||||||
|
call term_wait(buf)
|
||||||
|
|
||||||
" Test that popup and previewwindow do not overlap.
|
" Test that popup and previewwindow do not overlap.
|
||||||
call term_sendkeys(buf, "o\<C-X>\<C-N>")
|
call term_sendkeys(buf, "o")
|
||||||
sleep 100m
|
call term_wait(buf, 100)
|
||||||
|
call term_sendkeys(buf, "\<C-X>\<C-N>")
|
||||||
call VerifyScreenDump(buf, 'Test_popup_and_previewwindow_01', {})
|
call VerifyScreenDump(buf, 'Test_popup_and_previewwindow_01', {})
|
||||||
|
|
||||||
call term_sendkeys(buf, "\<Esc>u")
|
call term_sendkeys(buf, "\<Esc>u")
|
||||||
|
@ -11,3 +11,47 @@ func Test_Psearch()
|
|||||||
call assert_equal(wincount, winnr('$'))
|
call assert_equal(wincount, winnr('$'))
|
||||||
bwipe
|
bwipe
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
func Test_window_preview()
|
||||||
|
" Open a preview window
|
||||||
|
pedit Xa
|
||||||
|
call assert_equal(2, winnr('$'))
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
|
||||||
|
" Go to the preview window
|
||||||
|
wincmd P
|
||||||
|
call assert_equal(1, &previewwindow)
|
||||||
|
call assert_equal('preview', win_gettype())
|
||||||
|
|
||||||
|
" Close preview window
|
||||||
|
wincmd z
|
||||||
|
call assert_equal(1, winnr('$'))
|
||||||
|
call assert_equal(0, &previewwindow)
|
||||||
|
|
||||||
|
call assert_fails('wincmd P', 'E441:')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_window_preview_from_help()
|
||||||
|
filetype on
|
||||||
|
call writefile(['/* some C code */'], 'Xpreview.c')
|
||||||
|
help
|
||||||
|
pedit Xpreview.c
|
||||||
|
wincmd P
|
||||||
|
call assert_equal(1, &previewwindow)
|
||||||
|
call assert_equal('c', &filetype)
|
||||||
|
wincmd z
|
||||||
|
|
||||||
|
filetype off
|
||||||
|
close
|
||||||
|
call delete('Xpreview.c')
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_multiple_preview_windows()
|
||||||
|
new
|
||||||
|
set previewwindow
|
||||||
|
new
|
||||||
|
call assert_fails('set previewwindow', 'E590:')
|
||||||
|
%bw!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -442,4 +442,302 @@ func Test_visual_put_in_block()
|
|||||||
bwipe!
|
bwipe!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
|
" Visual modes (v V CTRL-V) followed by an operator; count; repeating
|
||||||
|
func Test_visual_mode_op()
|
||||||
|
new
|
||||||
|
call append(0, '')
|
||||||
|
|
||||||
|
call setline(1, 'apple banana cherry')
|
||||||
|
call cursor(1, 1)
|
||||||
|
normal lvld.l3vd.
|
||||||
|
call assert_equal('a y', getline(1))
|
||||||
|
|
||||||
|
call setline(1, ['line 1 line 1', 'line 2 line 2', 'line 3 line 3',
|
||||||
|
\ 'line 4 line 4', 'line 5 line 5', 'line 6 line 6'])
|
||||||
|
call cursor(1, 1)
|
||||||
|
exe "normal Vcnewline\<Esc>j.j2Vd."
|
||||||
|
call assert_equal(['newline', 'newline'], getline(1, '$'))
|
||||||
|
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call setline(1, ['xxxxxxxxxxxxx', 'xxxxxxxxxxxxx', 'xxxxxxxxxxxxx',
|
||||||
|
\ 'xxxxxxxxxxxxx'])
|
||||||
|
exe "normal \<C-V>jlc \<Esc>l.l2\<C-V>c----\<Esc>l."
|
||||||
|
call assert_equal([' --------x',
|
||||||
|
\ ' --------x',
|
||||||
|
\ 'xxxx--------x',
|
||||||
|
\ 'xxxx--------x'], getline(1, '$'))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Visual mode maps (movement and text object)
|
||||||
|
" Visual mode maps; count; repeating
|
||||||
|
" - Simple
|
||||||
|
" - With an Ex command (custom text object)
|
||||||
|
func Test_visual_mode_maps()
|
||||||
|
new
|
||||||
|
call append(0, '')
|
||||||
|
|
||||||
|
func SelectInCaps()
|
||||||
|
let [line1, col1] = searchpos('\u', 'bcnW')
|
||||||
|
let [line2, col2] = searchpos('.\u', 'nW')
|
||||||
|
call setpos("'<", [0, line1, col1, 0])
|
||||||
|
call setpos("'>", [0, line2, col2, 0])
|
||||||
|
normal! gv
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
vnoremap W /\u/s-1<CR>
|
||||||
|
vnoremap iW :<C-U>call SelectInCaps()<CR>
|
||||||
|
|
||||||
|
call setline(1, 'KiwiRaspberryDateWatermelonPeach')
|
||||||
|
call cursor(1, 1)
|
||||||
|
exe "normal vWcNo\<Esc>l.fD2vd."
|
||||||
|
call assert_equal('NoNoberryach', getline(1))
|
||||||
|
|
||||||
|
call setline(1, 'JambuRambutanBananaTangerineMango')
|
||||||
|
call cursor(1, 1)
|
||||||
|
exe "normal llviWc-\<Esc>l.l2vdl."
|
||||||
|
call assert_equal('--ago', getline(1))
|
||||||
|
|
||||||
|
vunmap W
|
||||||
|
vunmap iW
|
||||||
|
bwipe!
|
||||||
|
delfunc SelectInCaps
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Operator-pending mode maps (movement and text object)
|
||||||
|
" - Simple
|
||||||
|
" - With Ex command moving the cursor
|
||||||
|
" - With Ex command and Visual selection (custom text object)
|
||||||
|
func Test_visual_oper_pending_mode_maps()
|
||||||
|
new
|
||||||
|
call append(0, '')
|
||||||
|
|
||||||
|
func MoveToCap()
|
||||||
|
call search('\u', 'W')
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
func SelectInCaps()
|
||||||
|
let [line1, col1] = searchpos('\u', 'bcnW')
|
||||||
|
let [line2, col2] = searchpos('.\u', 'nW')
|
||||||
|
call setpos("'<", [0, line1, col1, 0])
|
||||||
|
call setpos("'>", [0, line2, col2, 0])
|
||||||
|
normal! gv
|
||||||
|
endfunction
|
||||||
|
|
||||||
|
onoremap W /\u/<CR>
|
||||||
|
onoremap <Leader>W :<C-U>call MoveToCap()<CR>
|
||||||
|
onoremap iW :<C-U>call SelectInCaps()<CR>
|
||||||
|
|
||||||
|
call setline(1, 'PineappleQuinceLoganberryOrangeGrapefruitKiwiZ')
|
||||||
|
call cursor(1, 1)
|
||||||
|
exe "normal cW-\<Esc>l.l2.l."
|
||||||
|
call assert_equal('----Z', getline(1))
|
||||||
|
|
||||||
|
call setline(1, 'JuniperDurianZ')
|
||||||
|
call cursor(1, 1)
|
||||||
|
exe "normal g?\WfD."
|
||||||
|
call assert_equal('WhavcreQhevnaZ', getline(1))
|
||||||
|
|
||||||
|
call setline(1, 'LemonNectarineZ')
|
||||||
|
call cursor(1, 1)
|
||||||
|
exe "normal yiWPlciWNew\<Esc>fr."
|
||||||
|
call assert_equal('LemonNewNewZ', getline(1))
|
||||||
|
|
||||||
|
ounmap W
|
||||||
|
ounmap <Leader>W
|
||||||
|
ounmap iW
|
||||||
|
bwipe!
|
||||||
|
delfunc MoveToCap
|
||||||
|
delfunc SelectInCaps
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
" Patch 7.3.879: Properly abort Operator-pending mode for "dv:<Esc>" etc.
|
||||||
|
func Test_op_pend_mode_abort()
|
||||||
|
new
|
||||||
|
call append(0, '')
|
||||||
|
|
||||||
|
call setline(1, ['zzzz', 'zzzz'])
|
||||||
|
call cursor(1, 1)
|
||||||
|
|
||||||
|
exe "normal dV:\<CR>dv:\<CR>"
|
||||||
|
call assert_equal(['zzz'], getline(1, 2))
|
||||||
|
set nomodifiable
|
||||||
|
call assert_fails('exe "normal d:\<CR>"', 'E21:')
|
||||||
|
set modifiable
|
||||||
|
call feedkeys("dv:\<Esc>dV:\<Esc>", 'xt')
|
||||||
|
call assert_equal(['zzz'], getline(1, 2))
|
||||||
|
set nomodifiable
|
||||||
|
let v:errmsg = ''
|
||||||
|
call feedkeys("d:\<Esc>", 'xt')
|
||||||
|
call assert_true(v:errmsg !~# '^E21:')
|
||||||
|
set modifiable
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_characterwise_visual_mode()
|
||||||
|
new
|
||||||
|
|
||||||
|
" characterwise visual mode: replace last line
|
||||||
|
$put ='a'
|
||||||
|
let @" = 'x'
|
||||||
|
normal v$p
|
||||||
|
call assert_equal('x', getline('$'))
|
||||||
|
|
||||||
|
" characterwise visual mode: delete middle line
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
normal G
|
||||||
|
normal kkv$d
|
||||||
|
call assert_equal(['', 'b', 'c'], getline(1, '$'))
|
||||||
|
|
||||||
|
" characterwise visual mode: delete middle two lines
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
normal Gkkvj$d
|
||||||
|
call assert_equal(['', 'c'], getline(1, '$'))
|
||||||
|
|
||||||
|
" characterwise visual mode: delete last line
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
normal Gv$d
|
||||||
|
call assert_equal(['', 'a', 'b', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
" characterwise visual mode: delete last two lines
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
normal Gkvj$d
|
||||||
|
call assert_equal(['', 'a', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_characterwise_select_mode()
|
||||||
|
new
|
||||||
|
|
||||||
|
" Select mode maps
|
||||||
|
snoremap <lt>End> <End>
|
||||||
|
snoremap <lt>Down> <Down>
|
||||||
|
snoremap <lt>Del> <Del>
|
||||||
|
|
||||||
|
" characterwise select mode: delete middle line
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal Gkkgh\<End>\<Del>"
|
||||||
|
call assert_equal(['', 'b', 'c'], getline(1, '$'))
|
||||||
|
|
||||||
|
" characterwise select mode: delete middle two lines
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal Gkkgh\<Down>\<End>\<Del>"
|
||||||
|
call assert_equal(['', 'c'], getline(1, '$'))
|
||||||
|
|
||||||
|
" characterwise select mode: delete last line
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal Ggh\<End>\<Del>"
|
||||||
|
call assert_equal(['', 'a', 'b', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
" characterwise select mode: delete last two lines
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal Gkgh\<Down>\<End>\<Del>"
|
||||||
|
call assert_equal(['', 'a', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
sunmap <lt>End>
|
||||||
|
sunmap <lt>Down>
|
||||||
|
sunmap <lt>Del>
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_linewise_select_mode()
|
||||||
|
new
|
||||||
|
|
||||||
|
" linewise select mode: delete middle line
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal GkkgH\<Del>"
|
||||||
|
call assert_equal(['', 'b', 'c'], getline(1, '$'))
|
||||||
|
|
||||||
|
|
||||||
|
" linewise select mode: delete middle two lines
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal GkkgH\<Down>\<Del>"
|
||||||
|
call assert_equal(['', 'c'], getline(1, '$'))
|
||||||
|
|
||||||
|
" linewise select mode: delete last line
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal GgH\<Del>"
|
||||||
|
call assert_equal(['', 'a', 'b'], getline(1, '$'))
|
||||||
|
|
||||||
|
" linewise select mode: delete last two lines
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['a', 'b', 'c'])
|
||||||
|
exe "normal GkgH\<Down>\<Del>"
|
||||||
|
call assert_equal(['', 'a'], getline(1, '$'))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_visual_mode_put()
|
||||||
|
new
|
||||||
|
|
||||||
|
" v_p: replace last character with line register at middle line
|
||||||
|
call append('$', ['aaa', 'bbb', 'ccc'])
|
||||||
|
normal G
|
||||||
|
-2yank
|
||||||
|
normal k$vp
|
||||||
|
call assert_equal(['', 'aaa', 'bb', 'aaa', '', 'ccc'], getline(1, '$'))
|
||||||
|
|
||||||
|
" v_p: replace last character with line register at middle line selecting
|
||||||
|
" newline
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['aaa', 'bbb', 'ccc'])
|
||||||
|
normal G
|
||||||
|
-2yank
|
||||||
|
normal k$v$p
|
||||||
|
call assert_equal(['', 'aaa', 'bb', 'aaa', 'ccc'], getline(1, '$'))
|
||||||
|
|
||||||
|
" v_p: replace last character with line register at last line
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['aaa', 'bbb', 'ccc'])
|
||||||
|
normal G
|
||||||
|
-2yank
|
||||||
|
normal $vp
|
||||||
|
call assert_equal(['', 'aaa', 'bbb', 'cc', 'aaa', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
" v_p: replace last character with line register at last line selecting
|
||||||
|
" newline
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', ['aaa', 'bbb', 'ccc'])
|
||||||
|
normal G
|
||||||
|
-2yank
|
||||||
|
normal $v$p
|
||||||
|
call assert_equal(['', 'aaa', 'bbb', 'cc', 'aaa', ''], getline(1, '$'))
|
||||||
|
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
|
func Test_select_mode_gv()
|
||||||
|
new
|
||||||
|
|
||||||
|
" gv in exclusive select mode after operation
|
||||||
|
call append('$', ['zzz ', 'äà '])
|
||||||
|
set selection=exclusive
|
||||||
|
normal Gkv3lyjv3lpgvcxxx
|
||||||
|
call assert_equal(['', 'zzz ', 'xxx '], getline(1, '$'))
|
||||||
|
|
||||||
|
" gv in exclusive select mode without operation
|
||||||
|
call deletebufline('', 1, '$')
|
||||||
|
call append('$', 'zzz ')
|
||||||
|
set selection=exclusive
|
||||||
|
exe "normal G0v3l\<Esc>gvcxxx"
|
||||||
|
call assert_equal(['', 'xxx '], getline(1, '$'))
|
||||||
|
|
||||||
|
set selection&vim
|
||||||
|
bwipe!
|
||||||
|
endfunc
|
||||||
|
|
||||||
" vim: shiftwidth=2 sts=2 expandtab
|
" vim: shiftwidth=2 sts=2 expandtab
|
||||||
|
@ -172,39 +172,6 @@ func Test_window_split_edit_bufnr()
|
|||||||
%bw!
|
%bw!
|
||||||
endfunc
|
endfunc
|
||||||
|
|
||||||
func Test_window_preview()
|
|
||||||
" Open a preview window
|
|
||||||
pedit Xa
|
|
||||||
call assert_equal(2, winnr('$'))
|
|
||||||
call assert_equal(0, &previewwindow)
|
|
||||||
|
|
||||||
" Go to the preview window
|
|
||||||
wincmd P
|
|
||||||
call assert_equal(1, &previewwindow)
|
|
||||||
|
|
||||||
" Close preview window
|
|
||||||
wincmd z
|
|
||||||
call assert_equal(1, winnr('$'))
|
|
||||||
call assert_equal(0, &previewwindow)
|
|
||||||
|
|
||||||
call assert_fails('wincmd P', 'E441:')
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_window_preview_from_help()
|
|
||||||
filetype on
|
|
||||||
call writefile(['/* some C code */'], 'Xpreview.c')
|
|
||||||
help
|
|
||||||
pedit Xpreview.c
|
|
||||||
wincmd P
|
|
||||||
call assert_equal(1, &previewwindow)
|
|
||||||
call assert_equal('c', &filetype)
|
|
||||||
wincmd z
|
|
||||||
|
|
||||||
filetype off
|
|
||||||
close
|
|
||||||
call delete('Xpreview.c')
|
|
||||||
endfunc
|
|
||||||
|
|
||||||
func Test_window_exchange()
|
func Test_window_exchange()
|
||||||
e Xa
|
e Xa
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user