GitHub

@@ -939,7 +939,7 @@ describe('CmdAtom', function()

939939

)

940940

end)

941941942-

it('an insert session atom captures its text', function()

942+

it('insert-session atom captures its text', function()

943943

fn.setline(1, { 'aaa' })

944944

feed('gg0')

945945

atoms_start()

@@ -966,6 +966,38 @@ describe('CmdAtom', function()

966966

eq({ type = 'insert', count = 3, text = 'Z' }, pick(atom_last(), 'type', 'count', 'text'))

967967

end)

968968969+

it('insert-session entered programmatically, still captures *user* input #41516', function()

970+

atoms_start()

971+

n.exec_lua([[

972+

vim.keymap.set('i', '<C-j>', function()

973+

vim.api.nvim_feedkeys(vim.api.nvim_replace_termcodes('<Esc>', true, false, true), 'n', false)

974+

vim.schedule(function()

975+

vim.api.nvim_feedkeys('i', 'n', false)

976+

end)

977+

end)

978+

]])

979+

local before = #atoms()

980+

feed('i')

981+

n.exec_lua('vim.wait(50)')

982+

feed('<C-j>')

983+

n.exec_lua('vim.wait(50)')

984+

feed('<Esc>')

985+

local evs = atoms()

986+

eq(before + 2, #evs)

987+

eq({ k('1i<Esc>'), k('1i<Esc>') }, { evs[#evs - 1].keys, evs[#evs].keys })

988+

-- Typed text within such a session lands in its atom...

989+

n.exec_lua([[vim.schedule(function() vim.api.nvim_feedkeys('i', 'n', false) end)]])

990+

n.exec_lua('vim.wait(50)')

991+

feed('hi<Esc>')

992+

eq({ text = 'hi', keys = k('1ihi<Esc>') }, pick(atom_last(), 'text', 'keys'))

993+

-- ...but with NO typed input within it, the session emits nothing.

994+

before = #atoms()

995+

n.exec_lua([[vim.schedule(function() vim.api.nvim_feedkeys('i', 'n', false) end)]])

996+

n.exec_lua('vim.wait(50)')

997+

n.exec_lua([[vim.api.nvim_feedkeys('\27', 'n', false)]])

998+

eq(before, #atoms())

999+

end)

1000+9691001

it("operatorfunc atom includes the getchar()'d payload", function()

9701002

n.exec(t_atom.minisurround_vim)

9711003

fn.setline(1, { 'alpha beta' })

Read the original on github.com ↗