mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
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:
parent
a166c2aadb
commit
e86b15b25c
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user