Skip to content

Commit 5edbf1c

Browse files
committed
Capital runs.
1 parent b818d35 commit 5edbf1c

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

plugin/textobj/variable-segment.vim

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ call textobj#user#plugin('variable', {
1616

1717

1818
function! s:select(object_type, right_boundary)
19-
let left_boundary = join(['_\i', '\l\u', '\a\d', '\d\a', '\<'], '\|')
20-
call search(left_boundary, 'bce')
19+
let left_boundaries = ['_\i', '\l\u', '\u\u\ze\l', '\a\d', '\d\a', '\<']
20+
call search(join(left_boundaries, '\|'), 'bce')
2121
let start_position = getpos('.')
2222

2323
call search('\>', 'c')
@@ -37,7 +37,8 @@ endfunction
3737

3838

3939
function! s:select_a()
40-
let right_boundary = join(['_', '\l\u', '\a\d', '\d\a', '\i\>'], '\|')
40+
let right_boundaries = ['_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\i\>']
41+
let right_boundary = join(right_boundaries, '\|')
4142
let [type, start_position, end_position] = s:select('a', right_boundary)
4243
let [_, start_line, start_column, _] = start_position
4344

@@ -64,8 +65,8 @@ endfunction
6465

6566

6667
function! s:select_i()
67-
let right_boundary = join(['\i_', '\l\u', '\a\d', '\d\a', '\i\>'], '\|')
68-
return s:select('i', right_boundary)
68+
let right_boundaries = ['\i_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\i\>']
69+
return s:select('i', join(right_boundaries, '\|'))
6970
endfunction
7071

7172

t/variable-segment.vim

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,20 @@ describe 'iv'
5656
Expect getline(1) == 'ABC456DEF'
5757
end
5858

59+
it 'recognizes weird capital runs considering the last to be a new group'
60+
put! = 'MyHTMLParser'
61+
normal! 4|
62+
normal civXML
63+
Expect getline(1) == 'MyXMLParser'
64+
end
65+
66+
it 'recognizes weird capital runs on the left'
67+
put! = 'MyHTMLParser'
68+
normal! 7|
69+
normal civNightmare
70+
Expect getline(1) == 'MyHTMLNightmare'
71+
end
72+
5973
it 'ignores leading snake underscores'
6074
put! = '_spam_eggs'
6175
normal! 3|
@@ -227,6 +241,20 @@ describe 'av'
227241
Expect getline(1) == 'ABCDEF'
228242
end
229243

244+
it 'recognizes weird capital runs considering the last to be a new group'
245+
put! = 'MyHTMLParser'
246+
normal! 4|
247+
normal dav
248+
Expect getline(1) == 'MyParser'
249+
end
250+
251+
it 'recognizes weird capital runs on the left'
252+
put! = 'MyHTMLParser'
253+
normal! 7|
254+
normal dav
255+
Expect getline(1) == 'MyHTML'
256+
end
257+
230258
it 'ignores leading snake underscores'
231259
put! = '_spam_eggs'
232260
normal! 3|

0 commit comments

Comments
 (0)