|
56 | 56 |
|
57 | 57 | func! sneak#label#to(s, v, label) abort |
58 | 58 | let seq = "" |
| 59 | + " TODO: handle g:sneak#absolute_dir=1 |
| 60 | + let forward = !a:s._reverse |
59 | 61 | while 1 |
60 | | - let choice = s:do_label(a:s, a:v, a:s._reverse, a:label) |
| 62 | + let choice = s:do_label(a:s, a:v, a:s._reverse, forward, a:label) |
61 | 63 | let seq .= choice |
62 | 64 | if choice =~# "^\<S-Tab>\\|\<BS>$" |
63 | | - call a:s.init(a:s._input, a:s._repeatmotion, 1) |
| 65 | + call a:s.init(a:s._input, a:s._repeatmotion, forward ? 1 : 0) |
64 | 66 | elseif choice ==# "\<Tab>" |
65 | | - call a:s.init(a:s._input, a:s._repeatmotion, 0) |
| 67 | + call a:s.init(a:s._input, a:s._repeatmotion, forward ? 0 : 1) |
66 | 68 | else |
67 | 69 | return seq |
68 | 70 | endif |
69 | 71 | endwhile |
70 | 72 | endf |
71 | 73 |
|
72 | | -func! s:do_label(s, v, reverse, label) abort "{{{ |
| 74 | +func! s:do_label(s, v, reverse, forward, label) abort "{{{ |
73 | 75 | let w = winsaveview() |
74 | 76 | call s:before() |
75 | 77 | let search_pattern = (a:s.prefix).(a:s.search).(a:s.get_onscreen_searchpattern(w)) |
@@ -108,8 +110,15 @@ func! s:do_label(s, v, reverse, label) abort "{{{ |
108 | 110 | \ : mappedto =~# '<Plug>Sneak\(_;\|Next\)' |
109 | 111 |
|
110 | 112 | if choice =~# "\\v^\<Tab>|\<S-Tab>|\<BS>$" " Decorate next N matches. |
111 | | - if (!a:reverse && choice ==# "\<Tab>") || (a:reverse && choice =~# "^\<S-Tab>\\|\<BS>$") |
112 | | - call cursor(overflow[0], overflow[1]) |
| 113 | + " TODO: handle g:sneak#absolute_dir=1 |
| 114 | + if a:forward |
| 115 | + if (!a:reverse && choice ==# "\<Tab>") || (a:reverse && choice =~# "^\<S-Tab>\\|\<BS>$") |
| 116 | + call cursor(overflow[0], overflow[1]) |
| 117 | + endif |
| 118 | + else |
| 119 | + if (a:reverse && choice ==# "\<Tab>") || (!a:reverse && choice =~# "^\<S-Tab>\\|\<BS>$") |
| 120 | + call cursor(overflow[0], overflow[1]) |
| 121 | + endif |
113 | 122 | endif " ...else we just switched directions, do not overflow. |
114 | 123 | elseif (strlen(g:sneak_opt.label_esc) && choice ==# g:sneak_opt.label_esc) |
115 | 124 | \ || -1 != index(["\<Esc>", "\<C-c>"], choice) |
|
0 commit comments