From 4b3284711056eec5e24c488719f34f61405bae4c Mon Sep 17 00:00:00 2001 From: Jacob Niehus Date: Wed, 21 Oct 2015 21:12:38 -0700 Subject: [PATCH] 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. --- jedi_vim.py | 10 ++++++++-- test/goto.vim | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) diff --git a/jedi_vim.py b/jedi_vim.py index 5af7238..f9db8de 100644 --- a/jedi_vim.py +++ b/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 diff --git a/test/goto.vim b/test/goto.vim index 75a7c6f..b65a1c7 100644 --- a/test/goto.vim +++ b/test/goto.vim @@ -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