mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-08 03:24:47 +08:00
Fix using tabs/splits instead of buffers
This commit is contained in:
36
jedi_vim.py
36
jedi_vim.py
@@ -245,9 +245,11 @@ 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:
|
||||||
if vim_eval('g:jedi#use_tag_stack') == '1':
|
if d.module_path != vim.current.buffer.name:
|
||||||
if not can_switch_buffers():
|
result = new_buffer(d.module_path, using_tagstack=True)
|
||||||
|
if not result:
|
||||||
return []
|
return []
|
||||||
|
if d.module_path and vim_eval('g:jedi#use_tag_stack') == '1':
|
||||||
with open(vim_eval('tempname()'), 'w') as f:
|
with open(vim_eval('tempname()'), 'w') as f:
|
||||||
tagname = d.name
|
tagname = d.name
|
||||||
while vim_eval('taglist("^%s$")' % tagname) != []:
|
while vim_eval('taglist("^%s$")' % tagname) != []:
|
||||||
@@ -260,12 +262,7 @@ def goto(mode="goto", no_output=False):
|
|||||||
vim.command('set tags+=%s' % f.name)
|
vim.command('set tags+=%s' % f.name)
|
||||||
vim.command('tjump %s' % tagname)
|
vim.command('tjump %s' % tagname)
|
||||||
vim.command('set tags-=%s' % f.name)
|
vim.command('set tags-=%s' % f.name)
|
||||||
else:
|
vim.current.window.cursor = d.line, d.column
|
||||||
if d.module_path != vim.current.buffer.name:
|
|
||||||
result = new_buffer(d.module_path)
|
|
||||||
if not result:
|
|
||||||
return []
|
|
||||||
vim.current.window.cursor = d.line, d.column
|
|
||||||
else:
|
else:
|
||||||
# multiple solutions
|
# multiple solutions
|
||||||
lst = []
|
lst = []
|
||||||
@@ -585,7 +582,7 @@ def py_import_completions():
|
|||||||
|
|
||||||
|
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def new_buffer(path, options=''):
|
def new_buffer(path, options='', using_tagstack=False):
|
||||||
# options are what you can to edit the edit options
|
# options are what you can to edit the edit options
|
||||||
if vim_eval('g:jedi#use_tabs_not_buffers') == '1':
|
if vim_eval('g:jedi#use_tabs_not_buffers') == '1':
|
||||||
_tabnew(path, options)
|
_tabnew(path, options)
|
||||||
@@ -604,9 +601,15 @@ def new_buffer(path, options=''):
|
|||||||
print('g:jedi#use_splits_not_buffers value is not correct, valid options are: %s' % ','.join(split_options.keys()))
|
print('g:jedi#use_splits_not_buffers value is not correct, valid options are: %s' % ','.join(split_options.keys()))
|
||||||
else:
|
else:
|
||||||
vim_command(split_options[user_split_option] + " %s" % path)
|
vim_command(split_options[user_split_option] + " %s" % path)
|
||||||
|
elif using_tagstack:
|
||||||
|
return True
|
||||||
else:
|
else:
|
||||||
if not can_switch_buffers():
|
if vim_eval("!&hidden && &modified") == '1':
|
||||||
return False
|
if vim_eval("bufname('%')") is None:
|
||||||
|
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
|
||||||
|
return False
|
||||||
|
else:
|
||||||
|
vim_command('w')
|
||||||
vim_command('edit %s %s' % (options, escape_file_path(path)))
|
vim_command('edit %s %s' % (options, escape_file_path(path)))
|
||||||
# sometimes syntax is being disabled and the filetype not set.
|
# sometimes syntax is being disabled and the filetype not set.
|
||||||
if vim_eval('!exists("g:syntax_on")') == '1':
|
if vim_eval('!exists("g:syntax_on")') == '1':
|
||||||
@@ -616,17 +619,6 @@ def new_buffer(path, options=''):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
@catch_and_print_exceptions
|
|
||||||
def can_switch_buffers():
|
|
||||||
if vim_eval("!&hidden && &modified") == '1':
|
|
||||||
if vim_eval("bufname('%')") is None:
|
|
||||||
echo_highlight('Cannot open a new buffer, use `:set hidden` or save your buffer')
|
|
||||||
return False
|
|
||||||
else:
|
|
||||||
vim_command('w')
|
|
||||||
return True
|
|
||||||
|
|
||||||
|
|
||||||
@catch_and_print_exceptions
|
@catch_and_print_exceptions
|
||||||
def _tabnew(path, options=''):
|
def _tabnew(path, options=''):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user