Skip to content

Commit

Permalink
Capital runs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Julian committed Dec 1, 2013
1 parent b818d35 commit 5edbf1c
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 5 deletions.
11 changes: 6 additions & 5 deletions plugin/textobj/variable-segment.vim
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ call textobj#user#plugin('variable', {


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

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


function! s:select_a()
let right_boundary = join(['_', '\l\u', '\a\d', '\d\a', '\i\>'], '\|')
let right_boundaries = ['_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\i\>']
let right_boundary = join(right_boundaries, '\|')
let [type, start_position, end_position] = s:select('a', right_boundary)
let [_, start_line, start_column, _] = start_position

Expand All @@ -64,8 +65,8 @@ endfunction


function! s:select_i()
let right_boundary = join(['\i_', '\l\u', '\a\d', '\d\a', '\i\>'], '\|')
return s:select('i', right_boundary)
let right_boundaries = ['\i_', '\l\u', '\u\u\l', '\a\d', '\d\a', '\i\>']
return s:select('i', join(right_boundaries, '\|'))
endfunction


Expand Down
28 changes: 28 additions & 0 deletions t/variable-segment.vim
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,20 @@ describe 'iv'
Expect getline(1) == 'ABC456DEF'
end

it 'recognizes weird capital runs considering the last to be a new group'
put! = 'MyHTMLParser'
normal! 4|
normal civXML
Expect getline(1) == 'MyXMLParser'
end

it 'recognizes weird capital runs on the left'
put! = 'MyHTMLParser'
normal! 7|
normal civNightmare
Expect getline(1) == 'MyHTMLNightmare'
end

it 'ignores leading snake underscores'
put! = '_spam_eggs'
normal! 3|
Expand Down Expand Up @@ -227,6 +241,20 @@ describe 'av'
Expect getline(1) == 'ABCDEF'
end

it 'recognizes weird capital runs considering the last to be a new group'
put! = 'MyHTMLParser'
normal! 4|
normal dav
Expect getline(1) == 'MyParser'
end

it 'recognizes weird capital runs on the left'
put! = 'MyHTMLParser'
normal! 7|
normal dav
Expect getline(1) == 'MyHTML'
end

it 'ignores leading snake underscores'
put! = '_spam_eggs'
normal! 3|
Expand Down

0 comments on commit 5edbf1c

Please sign in to comment.