lsp/make_position_param(): handle empty buffer #12825

Fix  #12623

problem: nvim_buf_get_lines(0) returns empty during startup, where no buffers are loaded yet.
solution: return empty object

Happens during startup, where buffer may not be loaded yet, because...
`source_startup_scripts()` is done before `edit_buffers()`:
9bb552875d/src/nvim/main.c (L362)
9bb552875d/src/nvim/main.c (L480)
This commit is contained in:
Gıyaseddin Tanrıkulu 2020-09-02 06:45:47 +03:00 committed by GitHub
parent a166c2aadb
commit e86b15b25c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1437,6 +1437,9 @@ local function make_position_param()
local row, col = unpack(api.nvim_win_get_cursor(0))
row = row - 1
local line = api.nvim_buf_get_lines(0, row, row+1, true)[1]
if not line then
return { line = 0; character = 0; }
end
col = str_utfindex(line, col)
return { line = row; character = col; }
end