Skip to content

Commit 6ca3eda

Browse files
committed
vim: textobj-fold: Fix incorrect selection for closed folds
1 parent a840a6b commit 6ca3eda

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

plugin/textobj/fold.vim

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ function! s:move_to_the_start_point()
8686
if s:in_open_fold_p()
8787
call s:move_to_the_start_of_open_fold()
8888
elseif s:in_closed_fold_p()
89-
" call s:move_to_the_start_of_closed_fold() " already at the point.
89+
call s:move_to_the_start_of_closed_fold()
9090
else
9191
call s:move_to_the_start_of_non_fold()
9292
endif
@@ -100,6 +100,10 @@ function! s:move_to_the_start_of_open_fold()
100100
endif
101101
endfunction
102102

103+
function! s:move_to_the_start_of_closed_fold()
104+
call cursor(foldclosed(line('.')), 1)
105+
endfunction
106+
103107
function! s:move_to_the_start_of_non_fold()
104108
let orig_line = line('.')
105109
normal! zk
@@ -115,7 +119,7 @@ function! s:move_to_the_end_point(mode, selection_starts_with_fold_p)
115119
if s:in_open_fold_p()
116120
call s:move_to_the_end_of_open_fold()
117121
elseif s:in_closed_fold_p()
118-
" call s:move_to_the_end_of_closed_fold() " already at the point.
122+
call s:move_to_the_end_of_closed_fold()
119123
else
120124
call s:move_to_the_end_of_non_fold()
121125
endif
@@ -163,6 +167,11 @@ function! s:move_to_the_end_of_open_fold()
163167
endif
164168
endfunction
165169

170+
function! s:move_to_the_end_of_closed_fold()
171+
call cursor(foldclosedend(line('.')), 0)
172+
normal! $
173+
endfunction
174+
166175
function! s:move_to_the_end_of_non_fold()
167176
let orig_line = line('.')
168177
normal! zj

0 commit comments

Comments
 (0)