Skip to content

Commit

Permalink
feat(output): auto-exit terminal mode
Browse files Browse the repository at this point in the history
See #67
  • Loading branch information
rcarriga committed Jul 17, 2022
1 parent ee97820 commit cb4e8c2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
5 changes: 5 additions & 0 deletions lua/neotest/async.lua
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ local async_wrapper = {
api = proxy_vim("api"),
fn = proxy_vim("fn"),
}
if false then
-- For type checking
async_wrapper.api = vim.api
async_wrapper.fn = vim.fn
end

setmetatable(async_wrapper, {
__index = function(_, k)
Expand Down
11 changes: 11 additions & 0 deletions lua/neotest/consumers/output.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ local function open_output(result, opts)
local dos_newlines = string.find(output, "\r\n") ~= nil
async.api.nvim_chan_send(chan, dos_newlines and output or output:gsub("\n", "\r\n"))
async.util.sleep(10) -- Wait for chan to send
async.api.nvim_create_autocmd("TermEnter", {
buffer = buf,
callback = function()
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes("<C-\\><C-N>", true, true, true),
"n",
false
)
end,
})

local lines = async.api.nvim_buf_get_lines(buf, 0, -1, false)
local width, height = 80, #lines
for i, line in ipairs(lines) do
Expand Down

0 comments on commit cb4e8c2

Please sign in to comment.