vim-patch:9.1.1167: mark '] wrong after copying text object (#32712)

Problem:  mark '] wrong after copying text object (ubaldot)
Solution: Adjust position of '] for non-linewise, exclusive motions
          (Jim Zhou)

related: vim/vim#16679
closes: vim/vim#16772

360a39ae6c

Co-authored-by: Jim Zhou <jimzhouzzy@gmail.com>
This commit is contained in:
zeertzjq
2025-03-04 07:05:05 +08:00
committed by GitHub
parent 65a3da8b15
commit 8ce504820a
2 changed files with 54 additions and 0 deletions

View File

@@ -2806,6 +2806,10 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
curbuf->b_op_start.col = 0;
curbuf->b_op_end.col = MAXCOL;
}
if (yank_type != kMTLineWise && !oap->inclusive) {
// Exclude the end position.
decl(&curbuf->b_op_end);
}
}
}

View File

@@ -1037,4 +1037,54 @@ func Test_register_cursor_column_negative()
call StopVimInTerminal(buf)
endfunc
" test '] mark generated by op_yank
func Test_mark_from_yank()
new
" double quote object
call setline(1, 'test "yank" mark')
normal! yi"
call assert_equal([0, 1, 10, 0], getpos("']"))
normal! ya"
call assert_equal(getpos("']"), [0, 1, 13, 0], getpos("']"))
" single quote object
call setline(1, 'test ''yank'' mark')
normal! yi'
call assert_equal([0, 1, 10, 0], getpos("']"))
normal! ya'
call assert_equal([0, 1, 13, 0], getpos("']"))
" paren object
call setline(1, 'test (yank) mark')
call cursor(1, 9)
normal! yi(
call assert_equal([0, 1, 10, 0], getpos("']"))
call cursor(1, 9)
normal! ya(
call assert_equal([0, 1, 11, 0], getpos("']"))
" brace object
call setline(1, 'test {yank} mark')
call cursor(1, 9)
normal! yi{
call assert_equal([0, 1, 10, 0], getpos("']"))
call cursor(1, 9)
normal! ya{
call assert_equal([0, 1, 11, 0], getpos("']"))
" bracket object
call setline(1, 'test [yank] mark')
call cursor(1, 9)
normal! yi[
call assert_equal([0, 1, 10, 0], getpos("']"))
call cursor(1, 9)
normal! ya[
call assert_equal([0, 1, 11, 0], getpos("']"))
" block object
call setline(1, 'test <yank> mark')
call cursor(1, 9)
normal! yi<
call assert_equal([0, 1, 10, 0], getpos("']"))
call cursor(1, 9)
normal! ya<
call assert_equal([0, 1, 11, 0], getpos("']"))
bw!
endfunc
" vim: shiftwidth=2 sts=2 expandtab