Skip to content
This repository has been archived by the owner on Sep 24, 2024. It is now read-only.

Commit

Permalink
fix highligh position with unicode characters for neovim
Browse files Browse the repository at this point in the history
  • Loading branch information
Kamilcuk committed Oct 18, 2021
1 parent 0925448 commit 87e110e
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions autoload/lsp_cxx_hl/textprop_nvim.vim
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@ function! s:buf_add_hl(buf, ns_id, hl_group,
" single line symbol
if a:s_line == a:e_line
if a:e_char - a:s_char > 0
call nvim_buf_add_highlight(a:buf, a:ns_id, a:hl_group,
\ a:s_line, a:s_char, a:e_char)
try
" Convert byte positions to column position in the file.
let line = getbufline(a:buf, a:s_line + 1)[0]
call nvim_buf_add_highlight(a:buf, a:ns_id, a:hl_group,
\ a:s_line,
\ byteidx(line, a:s_char),
\ byteidx(line, a:e_char))
" If the user fastly edits the file, this can be slower then the
" edits, and `getbufline` can return zero lines or these columns
" may just not exists anymore.
catch /Column value outside range/
catch /^Vim\%((\a\+)\)\=:E684/
endtry
return
else
return
Expand Down

0 comments on commit 87e110e

Please sign in to comment.