Commits

ZyX_I committed 597dbdc

Fix utils.run: when working with unnamed buffers it may not restore PWD

  • Participants
  • Parent commits 3e353c3

Comments (0)

Files changed (1)

File autoload/aurum/drivers/common/utils.vim

         let savedlazyredraw=&lazyredraw
         let savedeventignore=&eventignore
         let savedbufhidden=&l:bufhidden
+        let savedpwd=fnamemodify('.', ':p')
         set eventignore=all
         set lazyredraw
         set bufhidden=hide
             silent execute '%!'.join(map(copy(a:cmd), 'shellescape(v:val, 1)'))
             let r=getline(1, '$')
         finally
-            execute 'silent buffer!' prevbufnr
-            call setbufvar(prevbufnr, 'bufhidden', savedbufhidden)
+            execute 'lcd' fnameescape(savedpwd)
+            if bufexists(prevbufnr)
+                execute 'silent buffer!' prevbufnr
+                call setbufvar(prevbufnr, 'bufhidden', savedbufhidden)
+            endif
             let &lazyredraw=savedlazyredraw
             let &eventignore=savedeventignore
         endtry