Commits

ZyX_I committed 2cb9f19

Improve error handling in srestore

  • Participants
  • Parent commits cff27ee

Comments (0)

Files changed (1)

autoload/aurum/record.vim

             \ 'recnof': 'No files were selected for commiting',
             \   'norm': 'Can’t remove file %s as it was not added',
             \   'noad': 'Can’t add file %s as it is already included',
+            \ 'nsbvar': 'Internal error: sbvar key is present and sbuf '.
+            \           'is pointing to unknown buffer. If you can reproduce '.
+            \           'this file a bug report',
         \}
 "▶1 commitvimdiffcb
 function s:F.commitvimdiffcb(file, bvar, hex)
 "▶1 srestore
 function s:F.srestore(bvar)
     let sbuf=get(a:bvar, 'sbuf', -1)
+    "▶2 Check sbuf existence
     if !bufexists(sbuf)
-        return s:F.unload(get(a:bvar, sbuf, 0))
+        if has_key(a:bvar, 'sbvar')
+            return s:F.unload(a:bvar.sbvar)
+        elseif has_key(s:_r.bufvars, sbuf)
+            return s:F.unload(s:_r.bufvars[sbuf])
+        else
+            call s:_f.throw('nsbvar')
+        endif
     endif
+    "▲2
     let sbvar=a:bvar.sbvar
     execute 'silent botright sbuffer' sbuf
     execute 'resize' s:F.getswheight()