fix: capture inline description for keywords like Host and User
Some checks failed
quality / changes (push) Has been cancelled
test / Test (Neovim nightly) (push) Has been cancelled
test / Test (Neovim stable) (push) Has been cancelled
quality / Lua Format Check (push) Has been cancelled
quality / Lua Lint Check (push) Has been cancelled
quality / Lua Type Check (push) Has been cancelled
quality / Markdown Format Check (push) Has been cancelled
Some checks failed
quality / changes (push) Has been cancelled
test / Test (Neovim nightly) (push) Has been cancelled
test / Test (Neovim stable) (push) Has been cancelled
quality / Lua Format Check (push) Has been cancelled
quality / Lua Lint Check (push) Has been cancelled
quality / Lua Type Check (push) Has been cancelled
quality / Markdown Format Check (push) Has been cancelled
Problem: keywords with description text on the same line (e.g. "Host Restricts the following...") had their first line of documentation silently dropped because the parser started collecting at the line after the keyword. Solution: extract trailing text from the keyword line and prepend it to the description block.
This commit is contained in:
parent
ff0b4ee048
commit
679a4bf804
2 changed files with 20 additions and 1 deletions
|
|
@ -96,7 +96,8 @@ local function parse_keywords(stdout)
|
||||||
for i, line in ipairs(lines) do
|
for i, line in ipairs(lines) do
|
||||||
local kw = line:match('^ (%u%a+)%s*$') or line:match('^ (%u%a+) ')
|
local kw = line:match('^ (%u%a+)%s*$') or line:match('^ (%u%a+) ')
|
||||||
if kw then
|
if kw then
|
||||||
defs[#defs + 1] = { line = i, keyword = kw }
|
local inline = line:match('^ %u%a+%s%s%s+(.+)')
|
||||||
|
defs[#defs + 1] = { line = i, keyword = kw, inline = inline }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -105,6 +106,9 @@ local function parse_keywords(stdout)
|
||||||
local block_end = (defs[idx + 1] and defs[idx + 1].line or #lines) - 1
|
local block_end = (defs[idx + 1] and defs[idx + 1].line or #lines) - 1
|
||||||
|
|
||||||
local desc_lines = {}
|
local desc_lines = {}
|
||||||
|
if def.inline then
|
||||||
|
desc_lines[#desc_lines + 1] = ' ' .. def.inline
|
||||||
|
end
|
||||||
for k = def.line + 1, block_end do
|
for k = def.line + 1, block_end do
|
||||||
desc_lines[#desc_lines + 1] = lines[k]
|
desc_lines[#desc_lines + 1] = lines[k]
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -146,6 +146,21 @@ describe('blink-cmp-ssh', function()
|
||||||
assert.is_truthy(strict.documentation.value:find('known_hosts'))
|
assert.is_truthy(strict.documentation.value:find('known_hosts'))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
it('includes inline description for keywords with text on the same line', function()
|
||||||
|
restores[#restores + 1] = mock_system()
|
||||||
|
local source = require('blink-cmp-ssh').new()
|
||||||
|
local items
|
||||||
|
source:get_completions({ line = '', cursor = { 1, 0 } }, function(response)
|
||||||
|
items = response.items
|
||||||
|
end)
|
||||||
|
local host = vim.iter(items):find(function(item)
|
||||||
|
return item.label == 'Host'
|
||||||
|
end)
|
||||||
|
assert.is_not_nil(host)
|
||||||
|
assert.is_not_nil(host.documentation)
|
||||||
|
assert.is_truthy(host.documentation.value:find('Restricts'))
|
||||||
|
end)
|
||||||
|
|
||||||
it('returns enum values after a known keyword', function()
|
it('returns enum values after a known keyword', function()
|
||||||
restores[#restores + 1] = mock_system()
|
restores[#restores + 1] = mock_system()
|
||||||
local source = require('blink-cmp-ssh').new()
|
local source = require('blink-cmp-ssh').new()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue