All tests pass

pull/3/head
Iron-E 4 years ago
parent 481ce853ca
commit 20fa75aa54
No known key found for this signature in database
GPG Key ID: 19B71B7B7B021D22

@ -19,7 +19,7 @@ let s:winOpenOpts = {
function! libmodal#_inputWith(indicator, completions)
function! LibmodalCompletionsProvider(argLead, cmdLine, cursorPos) abort closure
return luaeval(
\ 'require("libmodal/src/Prompt/").createCompletionsProvider(_A[1])(_A[2], _A[3], _A[4])',
\ 'require("libmodal/src/Prompt").createCompletionsProvider(_A[1])(_A[2], _A[3], _A[4])',
\ [a:completions, a:argLead, a:cmdLine, a:cursorPos]
\)
endfunction

@ -138,16 +138,14 @@ function Prompt.createCompletionsProvider(completions)
-- replace conjoining characters with spaces.
local spacedArgLead = argLead
for _, replacement in ipairs(_REPLACEMENTS) do
spacedArgLead, _ = string.gsub(spacedArgLead, replacement, ' ')
spacedArgLead, _ = string.gsub(spacedArgLead, vim.pesc(replacement), ' ')
end
-- split the spaced version of `argLead`.
local splitArgLead = vim.split(spacedArgLead, ' ', true)
print(spacedArgLead)
-- make sure the user is in a position were this function
-- will provide accurate completions.
--[[ make sure the user is in a position were this function
will provide accurate completions.]]
if #splitArgLead > 1 then
return nil
end
@ -158,13 +156,9 @@ function Prompt.createCompletionsProvider(completions)
-- get all matches from the completions list.
local matches = {}
for _, completion in ipairs(completions) do
print('testing ' .. word .. ' against ' .. string.upper(completion))
-- test if `word` is inside of `completions`:`v`, ignoring case.
if string.match(vim.pesc(string.upper(completion)), word) then
print('>>match')
matches[#matches + 1] = completion -- preserve case when providing completions.
else
print('>>nomatch')
end
end
return matches

Loading…
Cancel
Save