@@ -620,23 +620,25 @@ function! go#util#HighlightPositions(group, pos) abort
620
620
621
621
" l:max is the 1-based index within the buffer of the first character after l:pos.
622
622
let l: max = line2byte (l: pos [0 ]) + l: pos [1 ] + l: pos [2 ] - 1
623
-
624
623
if has (' patch-8.2.115' )
625
624
" Use byte2line as long as 8.2.115 (which resolved
626
625
" https://github.com/vim/vim/issues/5334) is available.
627
- let l: end_lnum = byte2line (l: max )
626
+ let l: end_lnum = byte2line (l: max )
628
627
629
- if l: pos [0 ] != l: end_lnum
630
- let l: end_col = l: max - line2byte (l: end_lnum )
631
- let l: prop = {' type' : a: group , ' end_lnum' : l: end_lnum , ' end_col' : l: end_col }
632
- endif
628
+ if l: pos [0 ] != l: end_lnum
629
+ let l: end_col = l: max - line2byte (l: end_lnum )
630
+ let l: prop = {' type' : a: group , ' end_lnum' : l: end_lnum , ' end_col' : l: end_col }
631
+ endif
633
632
elseif l: pos [1 ] + l: pos [2 ] - 1 > len (l: line )
634
633
let l: end_lnum = l: pos [0 ]
635
- let l: end_col = l: pos [1 ] + l: pos [2 ] - 1
636
634
while line2byte (l: end_lnum+ 1 ) < l: max
637
635
let l: end_lnum += 1
638
- let l: end_col -= line2byte (l: end_lnum )
639
636
endwhile
637
+
638
+ " l:end_col is the full length - the byte position of l:end_lnum +
639
+ " the number of newlines (number of newlines is l:end_lnum -
640
+ " l:pos[0].
641
+ let l: end_col = l: max - line2byte (l: end_lnum ) + l: end_lnum - l: pos [0 ]
640
642
let l: prop = {' type' : a: group , ' end_lnum' : l: end_lnum , ' end_col' : l: end_col }
641
643
endif
642
644
call prop_add (l: pos [0 ], l: pos [1 ], l: prop )
0 commit comments