Skip to content

Commit

Permalink
Merge pull request #57 from kana/fix-c
Browse files Browse the repository at this point in the history
Fix <SID>(restore-marks) not to leave in buffer.
Close gh-56.
  • Loading branch information
kana authored Sep 25, 2017
2 parents ecfb9ae + 6d2f502 commit 2950a99
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 3 deletions.
2 changes: 2 additions & 0 deletions autoload/textobj/user.vim
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,9 @@ function! s:fail(interface_key_mapping_lhs)
endfunction

noremap <expr> <SID>(save-marks) <SID>save_marks()
noremap! <expr> <SID>(save-marks) <SID>save_marks()
noremap <expr> <SID>(restore-marks) <SID>restore_marks()
noremap! <expr> <SID>(restore-marks) <SID>restore_marks()
let s:original_marks = {}

Expand Down
27 changes: 24 additions & 3 deletions t/keep-marks.vim
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ describe 'Custom text object'
\ ' qux()',
\ '}',
\ ]
let @0 = '*nothing yanked*'
silent $ delete _
let @" = '*nothing changed*'
execute 'normal!' "1G2|vj\<Esc>"
end

Expand All @@ -41,7 +42,7 @@ describe 'Custom text object'

context 'defined by a function'
it 'keeps ''< and ''> marks'
Expect @0 ==# '*nothing yanked*'
Expect @0 ==# '*nothing changed*'
Expect [line("'<"), col("'<")] == [1, 2]
Expect [line("'>"), col("'>")] == [2, 2]

Expand All @@ -55,7 +56,7 @@ describe 'Custom text object'

context 'defined by a pattern'
it 'keeps ''< and ''> marks'
Expect @0 ==# '*nothing yanked*'
Expect @0 ==# '*nothing changed*'
Expect [line("'<"), col("'<")] == [1, 2]
Expect [line("'>"), col("'>")] == [2, 2]

Expand All @@ -66,6 +67,26 @@ describe 'Custom text object'
Expect [line("'>"), col("'>")] == [2, 2]
end
end

context 'combined with operator c'
it 'also works fine'
Expect @" ==# '*nothing changed*'
Expect [line("'<"), col("'<")] == [1, 2]
Expect [line("'>"), col("'>")] == [2, 2]

normal 3Gcilxyzzy

Expect @" ==# 'qux()'
Expect getline(1, '$') ==# [
\ 'if (!foo) {',
\ ' bar = ''baz''',
\ ' xyzzy',
\ '}',
\ ]
Expect [line("'<"), col("'<")] == [1, 2]
Expect [line("'>"), col("'>")] == [2, 2]
end
end
end

" __END__ "{{{1
Expand Down

0 comments on commit 2950a99

Please sign in to comment.