mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-08 03:24:47 +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)."
|
echo_highlight("Builtin modules cannot be displayed (%s)."
|
||||||
% d.desc_with_module)
|
% d.desc_with_module)
|
||||||
else:
|
else:
|
||||||
|
using_tagstack = vim_eval('g:jedi#use_tag_stack') == '1'
|
||||||
if d.module_path != vim.current.buffer.name:
|
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:
|
if not result:
|
||||||
return []
|
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:
|
with NamedTemporaryFile('w', prefix=vim_eval('tempname()')) as f:
|
||||||
tagname = d.name
|
tagname = d.name
|
||||||
f.write('{0}\t{1}\t{2}'.format(tagname, d.module_path,
|
f.write('{0}\t{1}\t{2}'.format(tagname, d.module_path,
|
||||||
'call cursor({0}, {1})'.format(d.line, d.column + 1)))
|
'call cursor({0}, {1})'.format(d.line, d.column + 1)))
|
||||||
f.flush()
|
f.flush()
|
||||||
old_tags = vim.eval('&tags')
|
old_tags = vim.eval('&tags')
|
||||||
|
old_wildignore = vim.eval('&wildignore')
|
||||||
try:
|
try:
|
||||||
|
# Clear wildignore to ensure tag file isn't ignored
|
||||||
|
vim.command('set wildignore=')
|
||||||
vim.command('set tags=%s' % f.name)
|
vim.command('set tags=%s' % f.name)
|
||||||
vim.command('tjump %s' % tagname)
|
vim.command('tjump %s' % tagname)
|
||||||
finally:
|
finally:
|
||||||
vim.command('set tags=%s' % old_tags)
|
vim.command('set tags=%s' % old_tags)
|
||||||
|
vim.command('let &wildignore = "%s"' % old_wildignore)
|
||||||
vim.current.window.cursor = d.line, d.column
|
vim.current.window.cursor = d.line, d.column
|
||||||
else:
|
else:
|
||||||
# multiple solutions
|
# multiple solutions
|
||||||
|
|||||||
@@ -177,4 +177,41 @@ describe 'goto_with_splits'
|
|||||||
end
|
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
|
" vim: et:ts=4:sw=4
|
||||||
|
|||||||
Reference in New Issue
Block a user