changeset 72:a987094d5ae6

Made the `Hgstatus` window refresh itself when needed.
author Ludovic Chabant <ludovic@chabant.com>
date Sun, 16 Feb 2014 17:31:18 -0800
parents 1fbba48019b5
children 785d1a1faa6c
files plugin/lawrencium.vim
diffstat 1 files changed, 24 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/plugin/lawrencium.vim	Sun Feb 16 16:00:16 2014 -0800
+++ b/plugin/lawrencium.vim	Sun Feb 16 17:31:18 2014 -0800
@@ -895,10 +895,16 @@
     endif
 endfunction
 
-function! s:HgStatus_Refresh() abort
-    " Just re-edit the buffer, it will reload the contents by calling
-    " the matching Mercurial command.
-    edit
+function! s:HgStatus_Refresh(...) abort
+    if a:0 == 0
+        " Just re-edit the buffer, it will reload the contents by calling
+        " the matching Mercurial command.
+        edit
+    else
+        " Re-edit the given buffer.
+        execute 'buf ' . a:1
+        edit
+    endif
 endfunction
 
 function! s:HgStatus_FileEdit() abort
@@ -943,8 +949,16 @@
         return
     endif
 
+    " Remember which buffer this is.
+    let l:status_nr = bufnr('%')
+
     " Run `Hgcommit` on those paths.
     call s:HgCommit(a:bang, a:vertical, l:filenames)
+
+    " At this point we should be in the commit message buffer.
+    " Let's refresh the status window when that buffer gets deleted.
+    let l:bufobj = s:buffer_obj()
+    call l:bufobj.OnDelete('call s:HgStatus_Refresh(' . l:status_nr . ')')
 endfunction
 
 function! s:HgStatus_Diff(vertical) abort
@@ -981,6 +995,9 @@
         call insert(l:filenames, l:message, 1)
     endif
     call l:repo.RunCommand('qnew', l:filenames)
+
+    " Refresh the status window.
+    call s:HgStatus_Refresh()
 endfunction
 
 function! s:HgStatus_QRefresh(linestart, lineend) abort
@@ -995,6 +1012,9 @@
     let l:repo = s:hg_repo()
     call insert(l:filenames, '-s', 0)
     call l:repo.RunCommand('qrefresh', l:filenames)
+
+    " Refresh the status window.
+    call s:HgStatus_Refresh()
 endfunction