fix(lsp): check if buffer was detached in on_init callback (#28914)

Co-authored-by: Jongwook Choi <wookayin@gmail.com>
This commit is contained in:
Ilia Choly
2024-05-23 09:17:53 -04:00
committed by GitHub
parent 2908f71dc9
commit af200c10cf
5 changed files with 71 additions and 40 deletions

View File

@@ -95,11 +95,11 @@ describe('semantic token highlighting', function()
},
},
handlers = {
['textDocument/semanticTokens/full'] = function()
return vim.fn.json_decode(response)
['textDocument/semanticTokens/full'] = function(_, _, callback)
callback(nil, vim.fn.json_decode(response))
end,
['textDocument/semanticTokens/full/delta'] = function()
return vim.fn.json_decode(edit_response)
['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
callback(nil, vim.fn.json_decode(edit_response))
end,
}
})
@@ -560,11 +560,11 @@ describe('semantic token highlighting', function()
},
},
handlers = {
['textDocument/semanticTokens/full'] = function()
return nil
['textDocument/semanticTokens/full'] = function(_, _, callback)
callback(nil, nil)
end,
['textDocument/semanticTokens/full/delta'] = function()
return nil
callback(nil, nil)
end,
}
})
@@ -608,11 +608,11 @@ describe('semantic token highlighting', function()
},
},
handlers = {
['textDocument/semanticTokens/full'] = function()
return vim.fn.json_decode(response)
['textDocument/semanticTokens/full'] = function(_, _, callback)
callback(nil, vim.fn.json_decode(response))
end,
['textDocument/semanticTokens/full/delta'] = function()
return vim.fn.json_decode(edit_response)
['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
callback(nil, vim.fn.json_decode(edit_response))
end,
}
})
@@ -1075,8 +1075,8 @@ b = "as"]],
},
},
handlers = {
['textDocument/semanticTokens/full'] = function()
return vim.fn.json_decode(resp)
['textDocument/semanticTokens/full'] = function(_, _, callback)
callback(nil, vim.fn.json_decode(resp))
end,
}
})
@@ -1461,11 +1461,11 @@ int main()
},
},
handlers = {
['textDocument/semanticTokens/full'] = function()
return vim.fn.json_decode(resp1)
['textDocument/semanticTokens/full'] = function(_, _, callback)
callback(nil, vim.fn.json_decode(resp1))
end,
['textDocument/semanticTokens/full/delta'] = function()
return vim.fn.json_decode(resp2)
['textDocument/semanticTokens/full/delta'] = function(_, _, callback)
callback(nil, vim.fn.json_decode(resp2))
end,
}
})