fix bug: open non-open files in vim
authorStefan Huber <shuber2@gmail.com>
Tue, 10 Jun 2008 16:30:32 +0000 (18:30 +0200)
committerStefan Huber <shuber2@gmail.com>
Tue, 10 Jun 2008 16:37:58 +0000 (18:37 +0200)
pygdb.vim

index 25b7fe1cada7436637d21f33aa987bfcf2931581..fc03b84404d48cf050f4f1116db99c5aeec2c6f2 100644 (file)
--- a/pygdb.vim
+++ b/pygdb.vim
@@ -65,6 +65,16 @@ def gdbToggleBreakpoint(lineno=None, file=None):
 def addBreakpoint(file, lineno, cond=None):
        global gdbBps
 
+       #If file is not open, open it
+       if not file in [b.name for b in vim.buffers]:
+               try:
+                       os.stat(file)
+                       vim.command(":e %s" % file)
+               except OSError:
+                       print "Warning: file '%s' does not exist! (Wrong client command?)" % file
+                       return
+
+
        #Determine a sign number
        signnum = gdbNewSignnum()
 
@@ -175,6 +185,7 @@ def gdbLoadConfig():
                removeBreakpoint(0)
 
        #Add breakpoints from configuration
+       cmdset = False
        for bp in conf.breakpoints:
 
                file = bp["file"]
@@ -183,8 +194,9 @@ def gdbLoadConfig():
                if file[0] != os.sep:
 
                        #We need the client command to expand the paths...
-                       while clientcmd == "":
+                       while clientcmd == "" or not cmdset:
                                clientcmd = vim.eval("input('Client commando: ', '%s')" % clientcmd).strip()
+                               cmdset = True
 
                        #Get the dirs where executeable is in
                        relcmd = string.split(clientcmd)[0]