From f550254e33e955091d7fc74d5cb2bd952c5aa4ef Mon Sep 17 00:00:00 2001 From: deris0126 Date: Sun, 21 Jul 2013 14:12:19 +0900 Subject: [PATCH 1/2] Fix wrong jump if no count is specified If jump next hunk with no count, it move last hunk of below hunks. v:count step is 0, 2, 3, 4..., so if no count is specified, next hunk is -1(this is last hunk of below hunks). Because of above reason, I change to use v:count1 instead of v:count. v:count1 step is 1, 2, 3, 4... . Closes #40. --- plugin/signify.vim | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/plugin/signify.vim b/plugin/signify.vim index e8931d3..b85725f 100644 --- a/plugin/signify.vim +++ b/plugin/signify.vim @@ -61,15 +61,15 @@ com! -nargs=0 -bar SyDebug call sy#debug#list_active_buffe " Init: mappings {{{1 if exists('g:signify_mapping_next_hunk') - execute 'nnoremap '. g:signify_mapping_next_hunk .' :execute v:count ."SignifyJumpToNextHunk"' + execute 'nnoremap '. g:signify_mapping_next_hunk .' :execute v:count1 ."SignifyJumpToNextHunk"' else - nnoremap gj :execute v:count .'SignifyJumpToNextHunk' + nnoremap gj :execute v:count1 .'SignifyJumpToNextHunk' endif if exists('g:signify_mapping_prev_hunk') - execute 'nnoremap '. g:signify_mapping_prev_hunk .' :execute v:count ."SignifyJumpToPrevHunk"' + execute 'nnoremap '. g:signify_mapping_prev_hunk .' :execute v:count1 ."SignifyJumpToPrevHunk"' else - nnoremap gk :execute v:count .'SignifyJumpToPrevHunk' + nnoremap gk :execute v:count1 .'SignifyJumpToPrevHunk' endif if exists('g:signify_mapping_toggle_highlight') From 3b96ea5cbef356fb6d9ca6ebf396cc34771c0b2c Mon Sep 17 00:00:00 2001 From: deris0126 Date: Sun, 21 Jul 2013 14:20:32 +0900 Subject: [PATCH 2/2] Make jumping behaviour more pragmatic This patch makes jumps go the the first/last hunk when the given count was bigger than the available hunks. E.g. when there are only 2 hunks and you use 4]c, the cursor jumps to the last hunk nevertheless. Before this patch the cursor wouldn't move at all (which mimics the standard behaviour of ]c/[c). Closes #41. --- autoload/sy/jump.vim | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/autoload/sy/jump.vim b/autoload/sy/jump.vim index 77e0c8d..1119bd3 100644 --- a/autoload/sy/jump.vim +++ b/autoload/sy/jump.vim @@ -12,7 +12,7 @@ function! sy#jump#next_hunk(count) let lnum = line('.') let hunks = filter(copy(g:sy[g:sy_path].hunks), 'v:val.start > lnum') - let hunk = get(hunks, a:count - 1, {}) + let hunk = get(hunks, a:count - 1, get(hunks, -1, {})) if !empty(hunk) execute 'sign jump '. hunk.ids[0] .' file='. g:sy_path @@ -28,7 +28,7 @@ function! sy#jump#prev_hunk(count) let lnum = line('.') let hunks = filter(copy(g:sy[g:sy_path].hunks), 'v:val.start < lnum') - let hunk = get(hunks, 0 - a:count, {}) + let hunk = get(hunks, 0 - a:count, get(hunks, 0, {})) if !empty(hunk) execute 'sign jump '. hunk.ids[0] .' file='. g:sy_path