Skip to content

Commit 7c684e4

Browse files
committed
Use iskeyword rather than isident, and add a test we respect it.
1 parent 2500bc1 commit 7c684e4

File tree

2 files changed

+25
-4
lines changed

2 files changed

+25
-4
lines changed

autoload/textobj/variable_segment.vim

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
function! s:select(object_type, right_boundary)
2-
let left_boundaries = ['_\+\i', '\<', '\l\u', '\u\u\ze\l', '\a\d', '\d\a']
2+
let left_boundaries = ['_\+\k', '\<', '\l\u', '\u\u\ze\l', '\a\d', '\d\a']
33
call search(join(left_boundaries, '\|'), 'bce')
44
let start_position = getpos('.')
55

@@ -19,12 +19,12 @@ function! s:select(object_type, right_boundary)
1919
endfunction
2020

2121
function! s:select_a()
22-
let right_boundaries = ['_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\i\>']
22+
let right_boundaries = ['_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\k\>']
2323
let right_boundary = join(right_boundaries, '\|')
2424
let [type, start_position, end_position] = s:select('a', right_boundary)
2525
let [_, start_line, start_column, _] = start_position
2626

27-
call search('\i\>', 'c')
27+
call search('\k\>', 'c')
2828
if end_position == getpos('.') &&
2929
\ getline(start_line)[start_column - 2] =~# '_'
3030
let start_position[2] -= 1
@@ -49,7 +49,7 @@ function! s:select_a()
4949
endfunction
5050

5151
function! s:select_i()
52-
let right_boundaries = ['\i_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\i\>']
52+
let right_boundaries = ['\k_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\k\>']
5353
return s:select('i', join(right_boundaries, '\|'))
5454
endfunction
5555

t/variable-segment.vim

+21
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,16 @@ describe 'iv'
205205
normal civone
206206
Expect getline(1) == 'one another'
207207
end
208+
209+
it 'respects &iskeyword'
210+
let original = &iskeyword
211+
set iskeyword=a-z,_,'
212+
put! = 'bag_of_spam'' stuff'
213+
normal! 9|
214+
normal civeggs_n'
215+
Expect getline(1) == "bag_of_eggs_n' stuff"
216+
let &iskeyword = original
217+
end
208218
end
209219

210220

@@ -404,6 +414,7 @@ describe 'av'
404414
normal dav
405415
Expect getline(1) == 'foo bazQuux'
406416
end
417+
407418
it 'selects leading small camels and swaps case even with tildeop'
408419
set tildeop " Vim default is notildeop
409420
put! = 'fooBarQuux'
@@ -413,4 +424,14 @@ describe 'av'
413424
Expect &tildeop == 1
414425
set notildeop
415426
end
427+
428+
it 'respects &iskeyword'
429+
let original = &iskeyword
430+
set iskeyword=a-z,_,'
431+
put! = 'bag_of_spam'' stuff'
432+
normal! 9|
433+
normal dav
434+
Expect getline(1) == "bag_of stuff"
435+
let &iskeyword = original
436+
end
416437
end

0 commit comments

Comments
 (0)