Fix invalid temporary text
This commit is contained in:
@@ -109,12 +109,13 @@ entry.get_word = function(self)
|
|||||||
end
|
end
|
||||||
elseif misc.safe(self.completion_item.insertText) then
|
elseif misc.safe(self.completion_item.insertText) then
|
||||||
word = str.trim(self.completion_item.insertText)
|
word = str.trim(self.completion_item.insertText)
|
||||||
|
if self.completion_item.insertTextFormat == types.lsp.InsertTextFormat.Snippet then
|
||||||
word = str.get_word(word)
|
word = str.get_word(word)
|
||||||
|
end
|
||||||
else
|
else
|
||||||
word = str.trim(self.completion_item.label)
|
word = str.trim(self.completion_item.label)
|
||||||
word = str.get_word(word, '')
|
|
||||||
end
|
end
|
||||||
return word
|
return str.oneline(word)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -275,7 +275,7 @@ describe('entry', function()
|
|||||||
insertTextFormat = 1,
|
insertTextFormat = 1,
|
||||||
insertText = '__init__(self) -> None:\n pass',
|
insertText = '__init__(self) -> None:\n pass',
|
||||||
})
|
})
|
||||||
assert.are.equal(e:get_vim_item(e:get_offset()).word, '__init__')
|
assert.are.equal(e:get_vim_item(e:get_offset()).word, '__init__(self) -> None:')
|
||||||
assert.are.equal(e:get_filter_text(), '__init__')
|
assert.are.equal(e:get_filter_text(), '__init__')
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
local config = require('cmp.config')
|
local config = require('cmp.config')
|
||||||
|
local async = require('cmp.utils.async')
|
||||||
local spec = require('cmp.utils.spec')
|
local spec = require('cmp.utils.spec')
|
||||||
|
|
||||||
local source = require('cmp.source')
|
local source = require('cmp.source')
|
||||||
@@ -85,10 +86,15 @@ describe('source', function()
|
|||||||
})
|
})
|
||||||
end,
|
end,
|
||||||
})
|
})
|
||||||
|
vim.wait(100, function() return s.status == source.SourceStatus.COMPLETED end, 100, false)
|
||||||
assert.is.truthy(s:complete(state.input('s'), function() end))
|
assert.is.truthy(s:complete(state.input('s'), function() end))
|
||||||
|
vim.wait(100, function() return s.status == source.SourceStatus.COMPLETED end, 100, false)
|
||||||
assert.is.truthy(s:complete(state.input('p'), function() end))
|
assert.is.truthy(s:complete(state.input('p'), function() end))
|
||||||
|
vim.wait(100, function() return s.status == source.SourceStatus.COMPLETED end, 100, false)
|
||||||
assert.is.truthy(s:complete(state.input('e'), function() end))
|
assert.is.truthy(s:complete(state.input('e'), function() end))
|
||||||
|
vim.wait(100, function() return s.status == source.SourceStatus.COMPLETED end, 100, false)
|
||||||
assert.is.truthy(s:complete(state.input('c'), function() end))
|
assert.is.truthy(s:complete(state.input('c'), function() end))
|
||||||
|
vim.wait(100, function() return s.status == source.SourceStatus.COMPLETED end, 100, false)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
|||||||
@@ -51,5 +51,20 @@ async.dedup = function()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---Wiat for callback.
|
||||||
|
---@param runner fun(done: function)
|
||||||
|
---@param timeout number
|
||||||
|
---@return any
|
||||||
|
async.sync = function(runner, timeout)
|
||||||
|
local done = false
|
||||||
|
local res = runner(function()
|
||||||
|
done = true
|
||||||
|
end)
|
||||||
|
vim.wait(timeout or 1000, function()
|
||||||
|
return done
|
||||||
|
end, 100, false)
|
||||||
|
return res
|
||||||
|
end
|
||||||
|
|
||||||
return async
|
return async
|
||||||
|
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ INVALID_CHARS[string.byte('[')] = true
|
|||||||
INVALID_CHARS[string.byte(' ')] = true
|
INVALID_CHARS[string.byte(' ')] = true
|
||||||
INVALID_CHARS[string.byte('\t')] = true
|
INVALID_CHARS[string.byte('\t')] = true
|
||||||
INVALID_CHARS[string.byte('\n')] = true
|
INVALID_CHARS[string.byte('\n')] = true
|
||||||
|
INVALID_CHARS[string.byte('\r')] = true
|
||||||
|
|
||||||
local PAIR_CHARS = {}
|
local PAIR_CHARS = {}
|
||||||
PAIR_CHARS[string.byte('[')] = string.byte(']')
|
PAIR_CHARS[string.byte('[')] = string.byte(']')
|
||||||
|
|||||||
Reference in New Issue
Block a user