This commit is contained in:
hrsh7th
2021-08-24 13:23:27 +09:00
parent ed4f2fc4a6
commit 7873adf9a8
2 changed files with 17 additions and 4 deletions

View File

@@ -109,11 +109,10 @@ entry.get_word = function(self)
end
elseif misc.safe(self.completion_item.insertText) then
word = str.trim(self.completion_item.insertText)
if self.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then
word = str.get_word(word)
end
word = str.get_word(word)
else
word = str.trim(self.completion_item.label)
word = str.get_word(word, '')
end
return word
end)

View File

@@ -243,7 +243,6 @@ describe('entry', function()
-- press g
state.input('$')
local e = entry.new(state.manual(), state.source(), {
detail = '\\Nico_URLConf',
kind = 6,
label = '$this',
sortText = '$this',
@@ -264,4 +263,19 @@ describe('entry', function()
assert.are.equal(e:get_vim_item(e:get_offset()).word, '$this')
assert.are.equal(e:get_filter_text(), '$this')
end)
it('[#47] word should not contain \\n character', function()
local state = spec.state('', 1, 1)
-- press g
state.input('_')
local e = entry.new(state.manual(), state.source(), {
kind = 6,
label = '__init__',
insertTextFormat = 1,
insertText = '__init__(self) -> None:\n pass',
})
assert.are.equal(e:get_vim_item(e:get_offset()).word, '__init__')
assert.are.equal(e:get_filter_text(), '__init__')
end)
end)