@@ -8,7 +8,7 @@ function! TextObjWordBasedColumn(textobj)
8
8
let start_col = virtcol (" '<" )
9
9
let stop_col = virtcol (" '>" )
10
10
let line_num = line (" ." )
11
- let indent_level = s: indent_levell (" ." )
11
+ let indent_level = s: indent_level (" ." )
12
12
let start_line = s: find_boundary_row (line_num, start_col, indent_level, -1 )
13
13
let stop_line = s: find_boundary_row (line_num, start_col, indent_level, 1 )
14
14
let whitespace_only = s: whitespace_column_wanted (start_line, stop_line, cursor_col)
@@ -84,18 +84,27 @@ function! s:whitespace_column_wanted(start_line, stop_line, cursor_col)
84
84
return 1
85
85
endfunction
86
86
87
- function ! s: find_boundary_row (line_num, start_col, indent_level, step)
88
- let non_blank = getline (a: line_num + a: step ) = ~ " [^ \t ]"
89
- let same_indent = s: indent_levell (a: line_num + a: step ) == a: indent_level
90
- let is_not_comment = ! s: is_comment (a: line_num + a: step , a: start_col )
91
- if same_indent && non_blank && is_not_comment
92
- return s: find_boundary_row (a: line_num + a: step , a: start_col , a: indent_level , a: step )
93
- else
94
- return a: line_num
87
+ function ! s: find_boundary_row (start_line, start_col, indent_level, step)
88
+ let current_line = a: start_line
89
+ let max_boundary = 0
90
+ if a: step == 1
91
+ let max_boundary = line (" $" )
95
92
endif
93
+ while current_line != max_boundary
94
+ let next_line = current_line + a: step
95
+ let non_blank = getline (next_line) = ~ " [^ \t ]"
96
+ let same_indent = s: indent_level (next_line) == a: indent_level
97
+ let is_not_comment = ! s: is_comment (next_line, a: start_col )
98
+ if same_indent && non_blank && is_not_comment
99
+ let current_line = next_line
100
+ else
101
+ return current_line
102
+ endif
103
+ endwhile
104
+ return max_boundary
96
105
endfunction
97
106
98
- function ! s: indent_levell (line_num)
107
+ function ! s: indent_level (line_num)
99
108
let line = getline (a: line_num )
100
109
return match (line , " [^ \t ]" )
101
110
endfunction
0 commit comments