mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 18:54:44 +08:00
Fix issues with wildignore and tag stack
Closes https://github.com/davidhalter/jedi-vim/pull/483. Fixes https://github.com/davidhalter/jedi-vim/issues/482.
This commit is contained in:
committed by
Daniel Hahler
parent
a5be01fb0b
commit
4b32847110
10
jedi_vim.py
10
jedi_vim.py
@@ -248,22 +248,28 @@ def goto(mode="goto", no_output=False):
|
||||
echo_highlight("Builtin modules cannot be displayed (%s)."
|
||||
% d.desc_with_module)
|
||||
else:
|
||||
using_tagstack = vim_eval('g:jedi#use_tag_stack') == '1'
|
||||
if d.module_path != vim.current.buffer.name:
|
||||
result = new_buffer(d.module_path, using_tagstack=True)
|
||||
result = new_buffer(d.module_path,
|
||||
using_tagstack=using_tagstack)
|
||||
if not result:
|
||||
return []
|
||||
if d.module_path and vim_eval('g:jedi#use_tag_stack') == '1':
|
||||
if d.module_path and using_tagstack:
|
||||
with NamedTemporaryFile('w', prefix=vim_eval('tempname()')) as f:
|
||||
tagname = d.name
|
||||
f.write('{0}\t{1}\t{2}'.format(tagname, d.module_path,
|
||||
'call cursor({0}, {1})'.format(d.line, d.column + 1)))
|
||||
f.flush()
|
||||
old_tags = vim.eval('&tags')
|
||||
old_wildignore = vim.eval('&wildignore')
|
||||
try:
|
||||
# Clear wildignore to ensure tag file isn't ignored
|
||||
vim.command('set wildignore=')
|
||||
vim.command('set tags=%s' % f.name)
|
||||
vim.command('tjump %s' % tagname)
|
||||
finally:
|
||||
vim.command('set tags=%s' % old_tags)
|
||||
vim.command('let &wildignore = "%s"' % old_wildignore)
|
||||
vim.current.window.cursor = d.line, d.column
|
||||
else:
|
||||
# multiple solutions
|
||||
|
||||
@@ -177,4 +177,41 @@ describe 'goto_with_splits'
|
||||
end
|
||||
|
||||
|
||||
describe 'goto_wildignore'
|
||||
before
|
||||
set filetype=python
|
||||
set wildignore=*,with\ spaces,*.pyc
|
||||
set hidden
|
||||
let g:jedi#use_tag_stack = 1
|
||||
let g:jedi#use_tabs_not_buffers = 0
|
||||
" Need to use splits for code coverage in new_buffer()
|
||||
let g:jedi#use_splits_not_buffers = 1
|
||||
|
||||
put = ['from subprocess import Popen', 'Popen']
|
||||
Expect CurrentBufferIsModule('subprocess') == 0
|
||||
silent normal G
|
||||
end
|
||||
|
||||
after
|
||||
bd!
|
||||
bd!
|
||||
set wildignore&vim
|
||||
end
|
||||
|
||||
it 'restores_wildignore'
|
||||
let before = &wildignore
|
||||
call jedi#goto()
|
||||
Expect getline('.') =~ 'Popen'
|
||||
Expect &wildignore == before
|
||||
end
|
||||
|
||||
it 'not_using_tagstack'
|
||||
let g:jedi#use_tag_stack = 0
|
||||
call jedi#goto()
|
||||
Expect CurrentBufferIsModule('subprocess') == 1
|
||||
Expect getline('.') =~ 'Popen'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
" vim: et:ts=4:sw=4
|
||||
|
||||
Reference in New Issue
Block a user