mirror of
https://github.com/davidhalter/jedi-vim.git
synced 2025-12-06 18:54:44 +08:00
Improved opening file in existing or new tab.
This commit is contained in:
@@ -302,27 +302,9 @@ def rename():
|
|||||||
|
|
||||||
|
|
||||||
def tabnew(path):
|
def tabnew(path):
|
||||||
|
"Open a file in a new tab or switch to an existing one"
|
||||||
path = os.path.abspath(path)
|
path = os.path.abspath(path)
|
||||||
for tab_nr in range(int(vim.eval("tabpagenr('$')"))):
|
vim.command('tab drop %s' % path)
|
||||||
for buf_nr in vim.eval("tabpagebuflist(%i + 1)" % tab_nr):
|
|
||||||
buf_nr = int(buf_nr) - 1
|
|
||||||
try:
|
|
||||||
buf_path = vim.buffers[buf_nr].name
|
|
||||||
except IndexError:
|
|
||||||
# Just do good old asking for forgiveness.
|
|
||||||
# don't know why this happens :-)
|
|
||||||
pass
|
|
||||||
else:
|
|
||||||
if buf_path == path:
|
|
||||||
# tab exists, just switch to that tab
|
|
||||||
vim.command('tabfirst | tabnext %i' % (tab_nr + 1))
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
continue
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# tab doesn't exist, add a new one.
|
|
||||||
vim.command('tabnew %s' % path)
|
|
||||||
|
|
||||||
|
|
||||||
def escape_file_path(path):
|
def escape_file_path(path):
|
||||||
|
|||||||
Reference in New Issue
Block a user