From e5d0b574be695f5a887504f86cb3a945af39c57d Mon Sep 17 00:00:00 2001 From: Yuri Pieters Date: Mon, 30 Dec 2019 12:09:02 +0000 Subject: [PATCH 1/2] Set 'notildeop' before preserving the case of the small camel When 'tildeop' is set the command `normal! l~` doesn't work. So back up the option, set `notildeop`, and restore it afterwards. --- autoload/textobj/variable_segment.vim | 3 +++ 1 file changed, 3 insertions(+) diff --git a/autoload/textobj/variable_segment.vim b/autoload/textobj/variable_segment.vim index 5c2995f..7671f8a 100644 --- a/autoload/textobj/variable_segment.vim +++ b/autoload/textobj/variable_segment.vim @@ -38,7 +38,10 @@ function! s:select_a() if start_column - 2 <= word_start || \ getline(start_line)[:start_column - 2] =~# '^_*$' call setpos('.', end_position) + let l:tildeop = &tildeop + set notildeop normal! l~ + let &tildeop = l:tildeop endif endif From c63c5e7d330edf430de4aed991daec3ccd1b0869 Mon Sep 17 00:00:00 2001 From: Yuri Pieters Date: Mon, 30 Dec 2019 14:53:58 +0000 Subject: [PATCH 2/2] Test that 'tildeop' being set does not effect 'av' --- t/variable-segment.vim | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/t/variable-segment.vim b/t/variable-segment.vim index b5f4252..aadafea 100644 --- a/t/variable-segment.vim +++ b/t/variable-segment.vim @@ -404,4 +404,13 @@ describe 'av' normal dav Expect getline(1) == 'foo bazQuux' end + it 'selects leading small camels and swaps case even with tildeop' + set tildeop " Vim default is notildeop + put! = 'fooBarQuux' + normal! 0 + normal dav + Expect getline(1) == 'barQuux' + Expect &tildeop == 1 + set notildeop + end end