Mercurial > vim-lawrencium
comparison plugin/lawrencium.vim @ 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 |
comparison
equal
deleted
inserted
replaced
71:1fbba48019b5 | 72:a987094d5ae6 |
---|---|
893 vnoremap <buffer> <silent> <C-A> :Hgstatusaddremove<cr> | 893 vnoremap <buffer> <silent> <C-A> :Hgstatusaddremove<cr> |
894 vnoremap <buffer> <silent> <C-S> :Hgstatuscommit<cr> | 894 vnoremap <buffer> <silent> <C-S> :Hgstatuscommit<cr> |
895 endif | 895 endif |
896 endfunction | 896 endfunction |
897 | 897 |
898 function! s:HgStatus_Refresh() abort | 898 function! s:HgStatus_Refresh(...) abort |
899 " Just re-edit the buffer, it will reload the contents by calling | 899 if a:0 == 0 |
900 " the matching Mercurial command. | 900 " Just re-edit the buffer, it will reload the contents by calling |
901 edit | 901 " the matching Mercurial command. |
902 edit | |
903 else | |
904 " Re-edit the given buffer. | |
905 execute 'buf ' . a:1 | |
906 edit | |
907 endif | |
902 endfunction | 908 endfunction |
903 | 909 |
904 function! s:HgStatus_FileEdit() abort | 910 function! s:HgStatus_FileEdit() abort |
905 " Get the path of the file the cursor is on. | 911 " Get the path of the file the cursor is on. |
906 let l:filename = s:HgStatus_GetSelectedFile() | 912 let l:filename = s:HgStatus_GetSelectedFile() |
941 if len(l:filenames) == 0 | 947 if len(l:filenames) == 0 |
942 call s:error("No files to commit in selection or file.") | 948 call s:error("No files to commit in selection or file.") |
943 return | 949 return |
944 endif | 950 endif |
945 | 951 |
952 " Remember which buffer this is. | |
953 let l:status_nr = bufnr('%') | |
954 | |
946 " Run `Hgcommit` on those paths. | 955 " Run `Hgcommit` on those paths. |
947 call s:HgCommit(a:bang, a:vertical, l:filenames) | 956 call s:HgCommit(a:bang, a:vertical, l:filenames) |
957 | |
958 " At this point we should be in the commit message buffer. | |
959 " Let's refresh the status window when that buffer gets deleted. | |
960 let l:bufobj = s:buffer_obj() | |
961 call l:bufobj.OnDelete('call s:HgStatus_Refresh(' . l:status_nr . ')') | |
948 endfunction | 962 endfunction |
949 | 963 |
950 function! s:HgStatus_Diff(vertical) abort | 964 function! s:HgStatus_Diff(vertical) abort |
951 " Open the file and run `Hgdiff` on it. | 965 " Open the file and run `Hgdiff` on it. |
952 call s:HgStatus_FileEdit() | 966 call s:HgStatus_FileEdit() |
979 call insert(l:filenames, '-m', 0) | 993 call insert(l:filenames, '-m', 0) |
980 let l:message = '"' . join(a:000, ' ') . '"' | 994 let l:message = '"' . join(a:000, ' ') . '"' |
981 call insert(l:filenames, l:message, 1) | 995 call insert(l:filenames, l:message, 1) |
982 endif | 996 endif |
983 call l:repo.RunCommand('qnew', l:filenames) | 997 call l:repo.RunCommand('qnew', l:filenames) |
998 | |
999 " Refresh the status window. | |
1000 call s:HgStatus_Refresh() | |
984 endfunction | 1001 endfunction |
985 | 1002 |
986 function! s:HgStatus_QRefresh(linestart, lineend) abort | 1003 function! s:HgStatus_QRefresh(linestart, lineend) abort |
987 " Get the selected filenames. | 1004 " Get the selected filenames. |
988 let l:filenames = s:HgStatus_GetSelectedFiles(a:linestart, a:lineend, ['M', 'A', 'R']) | 1005 let l:filenames = s:HgStatus_GetSelectedFiles(a:linestart, a:lineend, ['M', 'A', 'R']) |
993 | 1010 |
994 " Run `Hg qrefresh` on those paths. | 1011 " Run `Hg qrefresh` on those paths. |
995 let l:repo = s:hg_repo() | 1012 let l:repo = s:hg_repo() |
996 call insert(l:filenames, '-s', 0) | 1013 call insert(l:filenames, '-s', 0) |
997 call l:repo.RunCommand('qrefresh', l:filenames) | 1014 call l:repo.RunCommand('qrefresh', l:filenames) |
1015 | |
1016 " Refresh the status window. | |
1017 call s:HgStatus_Refresh() | |
998 endfunction | 1018 endfunction |
999 | 1019 |
1000 | 1020 |
1001 function! s:HgStatus_GetSelectedFile() abort | 1021 function! s:HgStatus_GetSelectedFile() abort |
1002 let l:filenames = s:HgStatus_GetSelectedFiles() | 1022 let l:filenames = s:HgStatus_GetSelectedFiles() |