neovim

Neovim text editor
git clone https://git.dasho.dev/neovim.git
Log | Files | Refs | README

commit f9bf64d74641f33961fe1d6c1592b65d2744298f
parent a30afeeb85176b83f3f540851218165e5d9c4c47
Author: glepnir <glephunter@gmail.com>
Date:   Wed, 11 Sep 2024 23:11:09 +0800

fix(lsp): check buffer is loaded and valid #30330

Problem: buffer mabye not valid when callback handler invoke.

Soliton: check buffer is valid and loaded in handler.
Diffstat:
Mruntime/lua/vim/lsp/inlay_hint.lua | 13++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/runtime/lua/vim/lsp/inlay_hint.lua b/runtime/lua/vim/lsp/inlay_hint.lua @@ -43,17 +43,16 @@ function M.on_inlayhint(err, result, ctx, _) return end local bufnr = assert(ctx.bufnr) - if util.buf_versions[bufnr] ~= ctx.version then + if + util.buf_versions[bufnr] ~= ctx.version + or not result + or not api.nvim_buf_is_loaded(bufnr) + or not bufstates[bufnr].enabled + then return end local client_id = ctx.client_id - if not result then - return - end local bufstate = bufstates[bufnr] - if not bufstate.enabled then - return - end if not (bufstate.client_hints and bufstate.version) then bufstate.client_hints = vim.defaulttable() bufstate.version = ctx.version