fix(neovim): let a pivi session keep one prompt and its unfinished draft
ee70235623de272377a02c3cee5070c5a8c45026
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
- Parent 1: f14cc9833776
bugabingas dorkfiles
ee70235623de272377a02c3cee5070c5a8c45026
Oliver Krylow <o.krylow@isp-insoft.de> ·
SSH signature · not checked
+43 / −1 text lines
+22 / −1 text lines
local existing = prompts[current.name] if existing and vim.api.nvim_buf_is_valid( existing ) then local win = vim.fn.bufwinid( existing ) if win == -1 and pcall( vim.cmd.split ) then win = vim.api.nvim_get_current_win() vim.api.nvim_win_set_buf( win, existing ) pcall( vim.api.nvim_win_set_height, win, 6 ) end if win ~= -1 then vim.api.nvim_set_current_win( win ) vim.cmd.startinsert() end return existing end prompts[current.name] = bufnr+21 / −0 text lines
it( 'reuses the prompt of a session and keeps an unfinished draft', function() local channel = fake.new() local current = session.create { spawn = channel.spawn, name = 'spec', extension = false, skill = false, env = {}, } local first = command.open_prompt( current ) vim.cmd.stopinsert() vim.api.nvim_buf_set_lines( first, 0, -1, false, { 'my unfinished draft', } ) local again = command.open_prompt( current ) vim.cmd.stopinsert() assert.equal( first, again ) assert.same( { 'my unfinished draft', }, vim.api.nvim_buf_get_lines( again, 0, -1, false ) ) local alive = 0 for _, bufnr in ipairs( vim.api.nvim_list_bufs() ) do if vim.bo[bufnr].filetype == command.input_filetype then alive = alive + 1 end end assert.equal( 1, alive ) end )