Skip to content

Commit

Permalink
fix error on editing empty file (#1154)
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd authored Apr 29, 2021
1 parent 80f4b26 commit b689884
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions autoload/lsp/utils/position.vim
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ function! s:to_col(expr, lnum, char) abort
endif
" a:expr is a file that is not yet loaded as a buffer
let l:lines = readfile(a:expr, '', a:lnum)
if l:lines == []
" when the file is empty. a:char should be 0 in the case
return a:char + 1
endif
endif
let l:linestr = l:lines[-1]
return strlen(strcharpart(l:linestr, 0, a:char)) + 1
Expand Down

0 comments on commit b689884

Please sign in to comment.