Re-fix autoindent with tests

This commit is contained in:
hrsh7th
2021-11-08 22:16:58 +09:00
parent 313773584d
commit 2fca457453
2 changed files with 11 additions and 2 deletions

View File

@@ -17,11 +17,11 @@ feedkeys.call = setmetatable({
local queue = {} local queue = {}
if #keys > 0 then if #keys > 0 then
table.insert(queue, { keymap.t('<Cmd>set lazyredraw<CR>'), 'n' }) table.insert(queue, { keymap.t('<Cmd>set lazyredraw<CR>'), 'n' })
table.insert(queue, { keymap.t('<Cmd>set paste<CR>'), 'n' }) table.insert(queue, { keymap.t('<Cmd>set textwidth=0<CR>'), 'n' })
table.insert(queue, { keymap.t('<Cmd>set eventignore=all<CR>'), 'n' }) table.insert(queue, { keymap.t('<Cmd>set eventignore=all<CR>'), 'n' })
table.insert(queue, { keys, string.gsub(mode, '[itx]', ''), true }) table.insert(queue, { keys, string.gsub(mode, '[itx]', ''), true })
table.insert(queue, { keymap.t('<Cmd>set %slazyredraw<CR>'):format(vim.o.lazyredraw and '' or 'no'), 'n' }) table.insert(queue, { keymap.t('<Cmd>set %slazyredraw<CR>'):format(vim.o.lazyredraw and '' or 'no'), 'n' })
table.insert(queue, { keymap.t('<Cmd>set %spaste<CR>'):format(vim.o.paste and '' or 'no'), 'n' }) table.insert(queue, { keymap.t('<Cmd>set textwidth=%s<CR>'):format(vim.bo.textwidth or 0), 'n' })
table.insert(queue, { keymap.t('<Cmd>set eventignore=%s<CR>'):format(vim.o.eventignore or ''), 'n' }) table.insert(queue, { keymap.t('<Cmd>set eventignore=%s<CR>'):format(vim.o.eventignore or ''), 'n' })
end end

View File

@@ -13,4 +13,13 @@ describe('feedkeys', function()
end) end)
assert.are.equal(reg, keymap.t('aiueo')) assert.are.equal(reg, keymap.t('aiueo'))
end) end)
it('autoindent', function()
vim.cmd([[set indentkeys+==end]])
feedkeys.call(keymap.t('iif<CR><Tab>end') .. keymap.autoindent(), 'nx')
assert.are.same(vim.api.nvim_buf_get_lines(0, 0, -1, false), {
'if',
'end'
})
end)
end) end)