Skip to content
Browse files

Fix buffer creation and fold remembering, #70 and #56

Use qstrahl's method for non-destructively opening a file. Also, remove
the empty buffer created by :tabnew
  • Loading branch information...
1 parent 4ae1f66 commit 674077400581e308de08410fafbab8a24c6f14a7 @joonty committed Apr 9, 2013
Showing with 22 additions and 5 deletions.
  1. +2 −2 plugin/python/vdebug/runner.py
  2. +12 −3 plugin/python/vdebug/ui/vimui.py
  3. +8 −0 plugin/vdebug.vim
View
4 plugin/python/vdebug/runner.py
@@ -69,9 +69,9 @@ def open(self):
else:
status = self.api.run()
self.refresh(status)
- except Exception as e:
+ except Exception:
self.close()
- raise e
+ raise
def set_features(self):
"""Evaluate vim dictionary of features and pass to debugger.
View
15 plugin/python/vdebug/ui/vimui.py
@@ -29,15 +29,21 @@ def open(self):
if self.is_open:
return
self.is_open = True
-
+
try:
+ existing_buffer = True
cur_buf_name = vim.eval("bufname('%')")
if cur_buf_name is None:
+ existing_buffer = False
cur_buf_name = ''
self.current_tab = vim.eval("tabpagenr()")
- vim.command('silent tabnew ' + cur_buf_name)
+ vim.command('silent tabnew')
+ self.empty_buf_num = vim.eval('bufnr("%")')
+ if existing_buffer:
+ vim.command('call vdebug:edit("%s")' % cur_buf_name)
+
self.tabnr = vim.eval("tabpagenr()")
srcwin_name = self.__get_srcwin_name()
@@ -170,6 +176,9 @@ def close(self):
if self.current_tab:
vim.command('tabn '+self.current_tab)
+ if self.empty_buf_num:
+ vim.command('bw' + self.empty_buf_num)
+
self.watchwin = None
self.stackwin = None
self.statuswin = None
@@ -221,7 +230,7 @@ def set_file(self,file):
self.file = file
vdebug.log.Log("Setting source file: "+file,vdebug.log.Logger.INFO)
self.focus()
- vim.command("silent edit " + file)
+ vim.command('call vdebug:edit("%s")' % file)
def set_line(self,lineno):
self.focus()
View
8 plugin/vdebug.vim
@@ -151,3 +151,11 @@ function! vdebug:get_visual_selection()
let lines[0] = lines[0][col1 - 1:]
return join(lines, "\n")
endfunction
+
+function vdebug:edit(filename)
+ try
+ execute 'buffer' fnameescape(a:filename)
+ catch /^Vim\%((\a\+)\)\=:E94/
+ execute 'silent edit' fnameescape(a:filename)
+ endtry
+endfunction

0 comments on commit 6740774

Please sign in to comment.
Something went wrong with that request. Please try again.