Skip to content

Commit b689884

Browse files
authored
fix error on editing empty file (#1154)
1 parent 80f4b26 commit b689884

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

autoload/lsp/utils/position.vim

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ function! s:to_col(expr, lnum, char) abort
1212
endif
1313
" a:expr is a file that is not yet loaded as a buffer
1414
let l:lines = readfile(a:expr, '', a:lnum)
15+
if l:lines == []
16+
" when the file is empty. a:char should be 0 in the case
17+
return a:char + 1
18+
endif
1519
endif
1620
let l:linestr = l:lines[-1]
1721
return strlen(strcharpart(l:linestr, 0, a:char)) + 1

0 commit comments

Comments
 (0)