mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	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.
This commit is contained in:
		| @@ -43,17 +43,16 @@ function M.on_inlayhint(err, result, ctx, _) | |||||||
|     return |     return | ||||||
|   end |   end | ||||||
|   local bufnr = assert(ctx.bufnr) |   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 |     return | ||||||
|   end |   end | ||||||
|   local client_id = ctx.client_id |   local client_id = ctx.client_id | ||||||
|   if not result then |  | ||||||
|     return |  | ||||||
|   end |  | ||||||
|   local bufstate = bufstates[bufnr] |   local bufstate = bufstates[bufnr] | ||||||
|   if not bufstate.enabled then |  | ||||||
|     return |  | ||||||
|   end |  | ||||||
|   if not (bufstate.client_hints and bufstate.version) then |   if not (bufstate.client_hints and bufstate.version) then | ||||||
|     bufstate.client_hints = vim.defaulttable() |     bufstate.client_hints = vim.defaulttable() | ||||||
|     bufstate.version = ctx.version |     bufstate.version = ctx.version | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 glepnir
					glepnir