mirror of
https://github.com/neovim/neovim.git
synced 2024-12-20 11:15:14 -07:00
vim-patch:8.2.4518: the binary tag search feature is always enabled
Problem: The binary tag search feature is always enabled.
Solution: Remove the #ifdefs. Add a few more tests. (Yegappan Lakshmanan,
closes vim/vim#9893)
655b734ee8
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
parent
6f08ea0131
commit
e41469a5b5
@ -1523,4 +1523,77 @@ func Test_stag_close_window_on_error()
|
||||
set tags&
|
||||
endfunc
|
||||
|
||||
" Test for 'tagbsearch' (binary search)
|
||||
func Test_tagbsearch()
|
||||
" If a tags file header says the tags are sorted, but the tags are actually
|
||||
" unsorted, then binary search should fail and linear search should work.
|
||||
call writefile([
|
||||
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "!_TAG_FILE_SORTED\t1\t/0=unsorted, 1=sorted, 2=foldcase/",
|
||||
\ "third\tXfoo\t3",
|
||||
\ "second\tXfoo\t2",
|
||||
\ "first\tXfoo\t1"],
|
||||
\ 'Xtags')
|
||||
set tags=Xtags
|
||||
let code =<< trim [CODE]
|
||||
int first() {}
|
||||
int second() {}
|
||||
int third() {}
|
||||
[CODE]
|
||||
call writefile(code, 'Xfoo')
|
||||
|
||||
enew
|
||||
set tagbsearch
|
||||
call assert_fails('tag first', 'E426:')
|
||||
call assert_equal('', bufname())
|
||||
call assert_fails('tag second', 'E426:')
|
||||
call assert_equal('', bufname())
|
||||
tag third
|
||||
call assert_equal('Xfoo', bufname())
|
||||
call assert_equal(3, line('.'))
|
||||
%bw!
|
||||
|
||||
set notagbsearch
|
||||
tag first
|
||||
call assert_equal('Xfoo', bufname())
|
||||
call assert_equal(1, line('.'))
|
||||
enew
|
||||
tag second
|
||||
call assert_equal('Xfoo', bufname())
|
||||
call assert_equal(2, line('.'))
|
||||
enew
|
||||
tag third
|
||||
call assert_equal('Xfoo', bufname())
|
||||
call assert_equal(3, line('.'))
|
||||
%bw!
|
||||
|
||||
" If a tags file header says the tags are unsorted, but the tags are
|
||||
" actually sorted, then binary search should work.
|
||||
call writefile([
|
||||
\ "!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted, 2=foldcase/",
|
||||
\ "first\tXfoo\t1",
|
||||
\ "second\tXfoo\t2",
|
||||
\ "third\tXfoo\t3"],
|
||||
\ 'Xtags')
|
||||
|
||||
set tagbsearch
|
||||
tag first
|
||||
call assert_equal('Xfoo', bufname())
|
||||
call assert_equal(1, line('.'))
|
||||
enew
|
||||
tag second
|
||||
call assert_equal('Xfoo', bufname())
|
||||
call assert_equal(2, line('.'))
|
||||
enew
|
||||
tag third
|
||||
call assert_equal('Xfoo', bufname())
|
||||
call assert_equal(3, line('.'))
|
||||
%bw!
|
||||
|
||||
call delete('Xtags')
|
||||
call delete('Xfoo')
|
||||
set tags& tagbsearch&
|
||||
endfunc
|
||||
|
||||
" vim: shiftwidth=2 sts=2 expandtab
|
||||
|
@ -36,6 +36,12 @@ func Test_taglist()
|
||||
call assert_equal('d', cmd[0]['kind'])
|
||||
call assert_equal('call cursor(3, 4)', cmd[0]['cmd'])
|
||||
|
||||
" Use characters with value > 127 in the tag extra field.
|
||||
call writefile([
|
||||
\ "vFoo\tXfoo\t4" .. ';"' .. "\ttypename:int\ta£££\tv",
|
||||
\ ], 'Xtags')
|
||||
call assert_equal('v', taglist('vFoo')[0].kind)
|
||||
|
||||
call assert_fails("let l=taglist([])", 'E730:')
|
||||
|
||||
call delete('Xtags')
|
||||
@ -221,6 +227,11 @@ func Test_format_error()
|
||||
endtry
|
||||
call assert_true(caught_exception)
|
||||
|
||||
" no field after the filename for a tag
|
||||
call writefile(["!_TAG_FILE_ENCODING\tutf-8\t//",
|
||||
\ "foo\tXfile"], 'Xtags')
|
||||
call assert_fails("echo taglist('foo')", 'E431:')
|
||||
|
||||
set tags&
|
||||
call delete('Xtags')
|
||||
endfunc
|
||||
|
Loading…
Reference in New Issue
Block a user