Mercurial > vim-lawrencium
comparison plugin/lawrencium.vim @ 113:8718e6dbea1e
Fix a bug with `:Hgstatus` showing diff summaries in its own window.
This could happen when the user would commit from the status window, and
do a `:Hgstatusvdiffsum` right away. It wouldn't find the previous window
because it would be gone (the commit message window), so it would split the
status window itself, which is often too small.
Now Lawrencium tries to avoid picking the status window itself, and will just
find any other window instead.
author | Ludovic Chabant <ludovic@chabant.com> |
---|---|
date | Sat, 27 Dec 2014 17:58:36 -0800 |
parents | b051b81cc365 |
children | facd2506066f |
comparison
equal
deleted
inserted
replaced
112:b051b81cc365 | 113:8718e6dbea1e |
---|---|
1144 let l:path = s:HgStatus_GetSelectedFile() | 1144 let l:path = s:HgStatus_GetSelectedFile() |
1145 " Reuse the same diff summary window | 1145 " Reuse the same diff summary window |
1146 let l:reuse_id = 'lawrencium_diffsum_for_' . bufnr('%') | 1146 let l:reuse_id = 'lawrencium_diffsum_for_' . bufnr('%') |
1147 let l:split_prev_win = (a:split < 3) | 1147 let l:split_prev_win = (a:split < 3) |
1148 let l:args = {'reuse_id': l:reuse_id, 'use_prev_win': l:split_prev_win, | 1148 let l:args = {'reuse_id': l:reuse_id, 'use_prev_win': l:split_prev_win, |
1149 \'split_mode': a:split} | 1149 \'avoid_win': winnr(), 'split_mode': a:split} |
1150 call s:HgDiffSummary(l:path, l:args) | 1150 call s:HgDiffSummary(l:path, l:args) |
1151 endfunction | 1151 endfunction |
1152 | 1152 |
1153 function! s:HgStatus_QNew(linestart, lineend, patchname, ...) abort | 1153 function! s:HgStatus_QNew(linestart, lineend, patchname, ...) abort |
1154 " Get the selected filenames. | 1154 " Get the selected filenames. |
1475 " First, see if we should reuse an existing window based on some buffer | 1475 " First, see if we should reuse an existing window based on some buffer |
1476 " variable. | 1476 " variable. |
1477 let l:target_winnr = -1 | 1477 let l:target_winnr = -1 |
1478 let l:split = get(l:valid_args, 'split_mode', 0) | 1478 let l:split = get(l:valid_args, 'split_mode', 0) |
1479 let l:reuse_id = get(l:valid_args, 'reuse_id', '') | 1479 let l:reuse_id = get(l:valid_args, 'reuse_id', '') |
1480 let l:avoid_id = get(l:valid_args, 'avoid_win', -1) | |
1480 if l:reuse_id != '' | 1481 if l:reuse_id != '' |
1481 let l:target_winnr = s:find_buffer_window(l:reuse_id, 1) | 1482 let l:target_winnr = s:find_buffer_window(l:reuse_id, 1) |
1482 if l:target_winnr > 0 && l:split != 3 | 1483 if l:target_winnr > 0 && l:split != 3 |
1483 " Unless we'll be opening in a new tab, don't split anymore, since | 1484 " Unless we'll be opening in a new tab, don't split anymore, since |
1484 " we found the exact window we wanted. | 1485 " we found the exact window we wanted. |
1486 endif | 1487 endif |
1487 call s:trace("Looking for window with '".l:reuse_id."', found: ".l:target_winnr) | 1488 call s:trace("Looking for window with '".l:reuse_id."', found: ".l:target_winnr) |
1488 endif | 1489 endif |
1489 " If we didn't find anything, see if we should use the current or previous | 1490 " If we didn't find anything, see if we should use the current or previous |
1490 " window. | 1491 " window. |
1491 if l:target_winnr < 0 | 1492 if l:target_winnr <= 0 |
1492 let l:use_prev_win = get(l:valid_args, 'use_prev_win', 0) | 1493 let l:use_prev_win = get(l:valid_args, 'use_prev_win', 0) |
1493 if l:use_prev_win | 1494 if l:use_prev_win |
1494 let l:target_winnr = winnr('#') | 1495 let l:target_winnr = winnr('#') |
1495 call s:trace("Will use previous window: ".l:target_winnr) | 1496 call s:trace("Will use previous window: ".l:target_winnr) |
1496 endif | 1497 endif |
1498 endif | |
1499 " And let's see if we have a window we should actually avoid. | |
1500 if l:avoid_id >= 0 && | |
1501 \(l:target_winnr == l:avoid_id || | |
1502 \(l:target_winnr <= 0 && winnr() == l:avoid_id)) | |
1503 for wnr in range(1, winnr('$')) | |
1504 if wnr != l:avoid_id | |
1505 call s:trace("Avoiding using window ".l:avoid_id. | |
1506 \", now using: ".wnr) | |
1507 let l:target_winnr = wnr | |
1508 break | |
1509 endif | |
1510 endfor | |
1497 endif | 1511 endif |
1498 " Now let's see what kind of split we want to use, if any. | 1512 " Now let's see what kind of split we want to use, if any. |
1499 let l:cmd = 'edit ' | 1513 let l:cmd = 'edit ' |
1500 if l:split == 1 | 1514 if l:split == 1 |
1501 let l:cmd = 'rightbelow split ' | 1515 let l:cmd = 'rightbelow split ' |