mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(lsp): suppress ContentModified errors from UI (#16904)
Fixes https://github.com/neovim/neovim/issues/16900 If clients receive a ContentModified error, it generally should not show it in the UI for the end-user. Clients can resend the request if they know how to do so. https://microsoft.github.io/language-server-protocol/specifications/specification-current/#implementationConsiderations
This commit is contained in:
		| @@ -439,14 +439,20 @@ for k, fn in pairs(M) do | |||||||
|     }) |     }) | ||||||
|  |  | ||||||
|     if err then |     if err then | ||||||
|       local client = vim.lsp.get_client_by_id(ctx.client_id) |  | ||||||
|       local client_name = client and client.name or string.format("client_id=%d", ctx.client_id) |  | ||||||
|       -- LSP spec: |       -- LSP spec: | ||||||
|       -- interface ResponseError: |       -- interface ResponseError: | ||||||
|       --  code: integer; |       --  code: integer; | ||||||
|       --  message: string; |       --  message: string; | ||||||
|       --  data?: string | number | boolean | array | object | null; |       --  data?: string | number | boolean | array | object | null; | ||||||
|       return err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) |  | ||||||
|  |       -- Per LSP, don't show ContentModified error to the user. | ||||||
|  |       if err.code ~= protocol.ErrorCodes.ContentModified then | ||||||
|  |         local client = vim.lsp.get_client_by_id(ctx.client_id) | ||||||
|  |         local client_name = client and client.name or string.format("client_id=%d", ctx.client_id) | ||||||
|  |  | ||||||
|  |         err_message(client_name .. ': ' .. tostring(err.code) .. ': ' .. err.message) | ||||||
|  |       end | ||||||
|  |       return | ||||||
|     end |     end | ||||||
|  |  | ||||||
|     return fn(err, result, ctx, config) |     return fn(err, result, ctx, config) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Sam McCall
					Sam McCall