Skip to content

Commit 40b2115

Browse files
inkarkatcoderifous
authored andcommitted
FIX: synID() needs byte column, not virtual column.
This matters when there are multi-byte, unprintable, or Tab characters, in which cases the virtual (screen) column is not equal to the byte index. Need to pass both columns to the s:find_boundary_row() function.
1 parent d1b92a3 commit 40b2115

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

plugin/textobj/word-column.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ function! TextObjWordBasedColumn(textobj)
99
let stop_col = virtcol("'>")
1010
let line_num = line(".")
1111
let indent_level = s:indent_level(".")
12-
let start_line = s:find_boundary_row(line_num, start_col, indent_level, -1)
13-
let stop_line = s:find_boundary_row(line_num, start_col, indent_level, 1)
12+
let start_line = s:find_boundary_row(line_num, col("'<"), start_col, indent_level, -1)
13+
let stop_line = s:find_boundary_row(line_num, col("'<"), start_col, indent_level, 1)
1414
let whitespace_only = s:whitespace_column_wanted(start_line, stop_line, cursor_col)
1515

1616
if (exists("g:textobj_word_column_no_smart_boundary_cols"))
@@ -84,7 +84,7 @@ function! s:whitespace_column_wanted(start_line, stop_line, cursor_col)
8484
return 1
8585
endfunction
8686

87-
function! s:find_boundary_row(start_line, start_col, indent_level, step)
87+
function! s:find_boundary_row(start_line, start_col, start_vcol, indent_level, step)
8888
let current_line = a:start_line
8989
let max_boundary = 0
9090
if a:step == 1
@@ -94,7 +94,7 @@ 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'
97+
let has_width = getline(next_line) =~ '\%'.a:start_vcol.'v'
9898
let is_not_comment = ! s:is_comment(next_line, a:start_col)
9999
if same_indent && non_blank && has_width && is_not_comment
100100
let current_line = next_line

0 commit comments

Comments
 (0)