aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMathias Fußenegger <mfussenegger@users.noreply.github.com>2022-01-13 10:47:36 +0100
committerGitHub <noreply@github.com>2022-01-13 01:47:36 -0800
commite7cd81156755c2f588752d469bceee9e48377b4e (patch)
tree9d310f2f1fc6dcc34ae4dc6abcc2986a9d48bfcc /test
parent43ef7df22d58a72e8b155265620f6c030900812e (diff)
downloadrneovim-e7cd81156755c2f588752d469bceee9e48377b4e.tar.gz
rneovim-e7cd81156755c2f588752d469bceee9e48377b4e.tar.bz2
rneovim-e7cd81156755c2f588752d469bceee9e48377b4e.zip
fix(lsp): handle negative activeSignature in signatureHelp (#17064)
omnisharp-roslyn can send negative values: { activeParameter = 0, activeSignature = -1, signatures = { { documentation = "", label = "TestEntity.TestEntity()", parameters = {} } } } In 3.16 of the specification `activeSignature` is defined as `uinteger` and therefore negative values shouldn't be allowed, but within 3.15 it was defined as `number` which makes me think we can be a bit lenient in this case and handle them. The expected behavior is quite clear: The active signature. If omitted or the value lies outside the range of `signatures` the value defaults to zero or is ignored if the `SignatureHelp` has no signatures. Fixes an error: util.lua:1685: attempt to get length of local 'lines' (a nil value) util.lua:1685: in function 'trim_empty_lines' handlers.lua:334: in function 'textDocument/signatureHelp'
Diffstat (limited to 'test')
-rw-r--r--test/functional/plugin/lsp_spec.lua21
1 files changed, 21 insertions, 0 deletions
diff --git a/test/functional/plugin/lsp_spec.lua b/test/functional/plugin/lsp_spec.lua
index 6a4730c5ac..91d80990c9 100644
--- a/test/functional/plugin/lsp_spec.lua
+++ b/test/functional/plugin/lsp_spec.lua
@@ -2333,6 +2333,27 @@ describe('LSP', function()
end)
end)
+ describe('lsp.util.convert_signature_help_to_markdown_lines', function()
+ it('can handle negative activeSignature', function()
+ local result = exec_lua[[
+ local signature_help = {
+ activeParameter = 0,
+ activeSignature = -1,
+ signatures = {
+ {
+ documentation = "",
+ label = "TestEntity.TestEntity()",
+ parameters = {}
+ },
+ }
+ }
+ return vim.lsp.util.convert_signature_help_to_markdown_lines(signature_help, 'cs', {','})
+ ]]
+ local expected = {'```cs', 'TestEntity.TestEntity()', '```', ''}
+ eq(expected, result)
+ end)
+ end)
+
describe('lsp.util.get_effective_tabstop', function()
local function test_tabstop(tabsize, softtabstop)
exec_lua(string.format([[