2017-03-21 18:20:06 -07:00
|
|
|
" Tests for :help
|
|
|
|
|
2022-11-06 07:15:59 -07:00
|
|
|
source check.vim
|
|
|
|
|
2017-03-21 18:20:06 -07:00
|
|
|
func Test_help_restore_snapshot()
|
|
|
|
help
|
|
|
|
set buftype=
|
|
|
|
help
|
|
|
|
edit x
|
|
|
|
help
|
|
|
|
helpclose
|
|
|
|
endfunc
|
|
|
|
|
2022-05-04 16:26:42 -07:00
|
|
|
func Test_help_restore_snapshot_split()
|
|
|
|
" Squeeze the unnamed buffer, Xfoo and the help one side-by-side and focus
|
|
|
|
" the first one before calling :help.
|
|
|
|
let bnr = bufnr()
|
|
|
|
botright vsp Xfoo
|
|
|
|
wincmd h
|
|
|
|
help
|
|
|
|
wincmd L
|
|
|
|
let g:did_bufenter = v:false
|
|
|
|
augroup T
|
|
|
|
au!
|
|
|
|
au BufEnter Xfoo let g:did_bufenter = v:true
|
|
|
|
augroup END
|
|
|
|
helpclose
|
|
|
|
augroup! T
|
|
|
|
" We're back to the unnamed buffer.
|
|
|
|
call assert_equal(bnr, bufnr())
|
|
|
|
" No BufEnter was triggered for Xfoo.
|
|
|
|
call assert_equal(v:false, g:did_bufenter)
|
|
|
|
|
|
|
|
close!
|
|
|
|
bwipe!
|
|
|
|
endfunc
|
|
|
|
|
2017-03-21 18:20:06 -07:00
|
|
|
func Test_help_errors()
|
|
|
|
call assert_fails('help doesnotexist', 'E149:')
|
|
|
|
call assert_fails('help!', 'E478:')
|
2022-02-08 00:09:54 -07:00
|
|
|
if has('multi_lang')
|
|
|
|
call assert_fails('help help@xy', 'E661:')
|
|
|
|
endif
|
|
|
|
|
|
|
|
let save_hf = &helpfile
|
|
|
|
set helpfile=help_missing
|
|
|
|
help
|
|
|
|
call assert_equal(1, winnr('$'))
|
|
|
|
call assert_notequal('help', &buftype)
|
|
|
|
let &helpfile = save_hf
|
|
|
|
|
|
|
|
call assert_fails('help ' . repeat('a', 1048), 'E149:')
|
2018-08-26 20:18:58 -07:00
|
|
|
|
|
|
|
new
|
|
|
|
set keywordprg=:help
|
|
|
|
call setline(1, " ")
|
|
|
|
call assert_fails('normal VK', 'E349:')
|
|
|
|
bwipe!
|
|
|
|
endfunc
|
|
|
|
|
2019-10-05 08:01:37 -07:00
|
|
|
func Test_help_expr()
|
|
|
|
help expr-!~?
|
|
|
|
call assert_equal('eval.txt', expand('%:t'))
|
|
|
|
close
|
|
|
|
endfunc
|
|
|
|
|
2018-08-26 20:18:58 -07:00
|
|
|
func Test_help_keyword()
|
|
|
|
new
|
|
|
|
set keywordprg=:help
|
|
|
|
call setline(1, " Visual ")
|
|
|
|
normal VK
|
|
|
|
call assert_match('^Visual mode', getline('.'))
|
|
|
|
call assert_equal('help', &ft)
|
|
|
|
close
|
|
|
|
bwipe!
|
2017-03-21 18:20:06 -07:00
|
|
|
endfunc
|
2018-08-27 07:14:57 -07:00
|
|
|
|
|
|
|
func Test_help_local_additions()
|
|
|
|
call mkdir('Xruntime/doc', 'p')
|
|
|
|
call writefile(['*mydoc.txt* my awesome doc'], 'Xruntime/doc/mydoc.txt')
|
|
|
|
call writefile(['*mydoc-ext.txt* my extended awesome doc'], 'Xruntime/doc/mydoc-ext.txt')
|
|
|
|
let rtp_save = &rtp
|
|
|
|
set rtp+=./Xruntime
|
|
|
|
help
|
|
|
|
1
|
|
|
|
call search('mydoc.txt')
|
|
|
|
call assert_equal('|mydoc.txt| my awesome doc', getline('.'))
|
|
|
|
1
|
|
|
|
call search('mydoc-ext.txt')
|
|
|
|
call assert_equal('|mydoc-ext.txt| my extended awesome doc', getline('.'))
|
|
|
|
close
|
|
|
|
|
|
|
|
call delete('Xruntime', 'rf')
|
|
|
|
let &rtp = rtp_save
|
|
|
|
endfunc
|
2020-12-18 23:36:47 -07:00
|
|
|
|
2022-06-30 19:54:41 -07:00
|
|
|
func Test_help_completion()
|
|
|
|
call feedkeys(":help :undo\<C-A>\<C-B>\"\<CR>", 'tx')
|
|
|
|
call assert_equal('"help :undo :undoj :undol :undojoin :undolist', @:)
|
|
|
|
endfunc
|
|
|
|
|
2020-12-18 23:36:47 -07:00
|
|
|
" Test for the :helptags command
|
2022-11-06 07:15:33 -07:00
|
|
|
" NOTE: if you run tests as root this will fail. Don't run tests as root!
|
2020-12-18 23:36:47 -07:00
|
|
|
func Test_helptag_cmd()
|
|
|
|
call mkdir('Xdir/a/doc', 'p')
|
|
|
|
|
|
|
|
" No help file to process in the directory
|
|
|
|
call assert_fails('helptags Xdir', 'E151:')
|
|
|
|
|
|
|
|
call writefile([], 'Xdir/a/doc/sample.txt')
|
|
|
|
|
|
|
|
" Test for ++t argument
|
|
|
|
helptags ++t Xdir
|
|
|
|
call assert_equal(["help-tags\ttags\t1"], readfile('Xdir/tags'))
|
|
|
|
call delete('Xdir/tags')
|
|
|
|
|
|
|
|
" Duplicate tags in the help file
|
|
|
|
call writefile(['*tag1*', '*tag1*', '*tag2*'], 'Xdir/a/doc/sample.txt')
|
|
|
|
call assert_fails('helptags Xdir', 'E154:')
|
|
|
|
|
|
|
|
call delete('Xdir', 'rf')
|
|
|
|
endfunc
|
|
|
|
|
2022-11-06 07:15:59 -07:00
|
|
|
func Test_helptag_cmd_readonly()
|
|
|
|
CheckUnix
|
|
|
|
CheckNotRoot
|
|
|
|
|
|
|
|
" Read-only tags file
|
|
|
|
call mkdir('Xdir/doc', 'p')
|
|
|
|
call writefile([''], 'Xdir/doc/tags')
|
|
|
|
call writefile([], 'Xdir/doc/sample.txt')
|
|
|
|
call setfperm('Xdir/doc/tags', 'r-xr--r--')
|
|
|
|
call assert_fails('helptags Xdir/doc', 'E152:', getfperm('Xdir/doc/tags'))
|
|
|
|
|
|
|
|
let rtp = &rtp
|
|
|
|
let &rtp = 'Xdir'
|
|
|
|
helptags ALL
|
|
|
|
let &rtp = rtp
|
|
|
|
|
|
|
|
call delete('Xdir/doc/tags')
|
|
|
|
|
|
|
|
" No permission to read the help file
|
|
|
|
call mkdir('Xdir/b/doc', 'p')
|
|
|
|
call writefile([], 'Xdir/b/doc/sample.txt')
|
|
|
|
call setfperm('Xdir/b/doc/sample.txt', '-w-------')
|
|
|
|
call assert_fails('helptags Xdir', 'E153:', getfperm('Xdir/b/doc/sample.txt'))
|
|
|
|
call delete('Xdir', 'rf')
|
|
|
|
endfunc
|
|
|
|
|
2022-09-21 19:48:46 -07:00
|
|
|
" Test for setting the 'helpheight' option in the help window
|
|
|
|
func Test_help_window_height()
|
2022-11-06 07:32:47 -07:00
|
|
|
let &cmdheight = &lines - 23
|
2022-09-21 19:48:46 -07:00
|
|
|
set helpheight=10
|
|
|
|
help
|
|
|
|
set helpheight=14
|
|
|
|
call assert_equal(14, winheight(0))
|
|
|
|
set helpheight& cmdheight=1
|
|
|
|
close
|
|
|
|
endfunc
|
|
|
|
|
2022-01-27 06:58:53 -07:00
|
|
|
func Test_help_long_argument()
|
|
|
|
try
|
|
|
|
exe 'help \%' .. repeat('0', 1021)
|
|
|
|
catch
|
|
|
|
call assert_match("E149:", v:exception)
|
|
|
|
endtry
|
|
|
|
endfunc
|
|
|
|
|
2022-01-29 16:15:22 -07:00
|
|
|
|
2020-12-18 23:36:47 -07:00
|
|
|
" vim: shiftwidth=2 sts=2 expandtab
|