mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-08 03:24:47 +08:00
Check if buffer can be hidden before tjump
This commit is contained in:
21
jedi_vim.py
21
jedi_vim.py
@@ -246,6 +246,8 @@ def goto(mode="goto", no_output=False):
|
|||||||
% d.desc_with_module)
|
% d.desc_with_module)
|
||||||
else:
|
else:
|
||||||
if vim_eval('g:jedi#use_tag_stack') == '1':
|
if vim_eval('g:jedi#use_tag_stack') == '1':
|
||||||
|
if not can_switch_buffers():
|
||||||
|
return []
|
||||||
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) != []:
|
||||||
@@ -603,12 +605,8 @@ def new_buffer(path, options=''):
|
|||||||
else:
|
else:
|
||||||
vim_command(split_options[user_split_option] + " %s" % path)
|
vim_command(split_options[user_split_option] + " %s" % path)
|
||||||
else:
|
else:
|
||||||
if vim_eval("!&hidden && &modified") == '1':
|
if not can_switch_buffers():
|
||||||
if vim_eval("bufname('%')") is None:
|
return False
|
||||||
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':
|
||||||
@@ -618,6 +616,17 @@ 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