Skip to content

Commit d1b92a3

Browse files
inkarkatcoderifous
authored andcommitted
FIX: Do not extend to lines that are shorter than the start column.
With the cursor on "ab", I get an invalid selection that extends to the "." of the second line (and a beep when smart boundaries are used), instead of the expected selection of lines 3 + 4. " Use real visual mode mappings to avoid the mapping delay when entering visual " mode with "v". xnoremap <silent> ab :<C-u>call TextObjWordBasedColumn("aw")<cr> xnoremap <silent> aB :<C-u>call TextObjWordBasedColumn("aW")<cr> This can be fixed by checking that there's actually a character at the start virtual column. The match for the exact column number also ensures that if the position is inside a Tab or in the middle of a double-width character, the selection will not be extended.
1 parent 0cf8ac2 commit d1b92a3

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

plugin/textobj/word-column.vim

100644100755
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,8 +94,9 @@ function! s:find_boundary_row(start_line, start_col, indent_level, step)
9494
let next_line = current_line + a:step
9595
let non_blank = getline(next_line) =~ "[^ \t]"
9696
let same_indent = s:indent_level(next_line) == a:indent_level
97+
let has_width = getline(next_line) =~ '\%'.a:start_col.'v'
9798
let is_not_comment = ! s:is_comment(next_line, a:start_col)
98-
if same_indent && non_blank && is_not_comment
99+
if same_indent && non_blank && has_width && is_not_comment
99100
let current_line = next_line
100101
else
101102
return current_line

0 commit comments

Comments
 (0)