Skip to content

Commit

Permalink
Fix get_buffers
Browse files Browse the repository at this point in the history
  • Loading branch information
quolpr committed Jan 15, 2025
1 parent bf2a084 commit 9f4045f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
18 changes: 9 additions & 9 deletions lua/quicktest/module.lua
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function M.run(adapter, params, config, opts)
end

local print_status = function()
for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
local line_count = vim.api.nvim_buf_line_count(buf)

local passedTime = vim.loop.now() - job.started_at
Expand All @@ -137,7 +137,7 @@ function M.run(adapter, params, config, opts)
end
end

for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
vim.api.nvim_buf_set_lines(buf, 0, -1, false, {})

ui.scroll_down(buf)
Expand All @@ -152,7 +152,7 @@ function M.run(adapter, params, config, opts)

if adapter.title then
local title = adapter.title(params)
for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
vim.api.nvim_buf_set_lines(buf, 0, -1, false, {
title,
"",
Expand All @@ -163,7 +163,7 @@ function M.run(adapter, params, config, opts)
ui.scroll_down(buf)
end
else
for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
vim.api.nvim_buf_set_lines(buf, 0, -1, false, {
"",
"",
Expand Down Expand Up @@ -199,7 +199,7 @@ function M.run(adapter, params, config, opts)
end
end

for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
local should_scroll = ui.should_continue_scroll(buf)

if result.type == "stdout" then
Expand Down Expand Up @@ -311,7 +311,7 @@ function M.kill_current_run()
vim.system({ "kill", tostring(current_job.pid) }):wait()
current_job = nil

for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
local line_count = vim.api.nvim_buf_line_count(buf)

local passedTime = vim.loop.now() - job.started_at
Expand All @@ -338,7 +338,7 @@ end
---@param mode WinModeWithoutAuto
function M.try_open_win(mode)
ui.try_open_win(mode)
for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
ui.scroll_down(buf)
end
end
Expand All @@ -356,7 +356,7 @@ function M.toggle_win(mode)
else
ui.try_open_win("split")

for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
ui.scroll_down(buf)
end
end
Expand All @@ -366,7 +366,7 @@ function M.toggle_win(mode)
else
ui.try_open_win("popup")

for _, buf in ipairs(ui.buffers) do
for _, buf in ipairs(ui.get_buffers()) do
ui.scroll_down(buf)
end
end
Expand Down
4 changes: 3 additions & 1 deletion lua/quicktest/ui.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,9 @@ local function get_popup_buf()
return get_or_create_buf("quicktest-popup")
end

M.buffers = { get_split_buf(), get_popup_buf() }
M.get_buffers = function()
return { get_split_buf(), get_popup_buf() }
end
M.is_split_opened = function()
return is_buf_visible(get_split_buf())
end
Expand Down

0 comments on commit 9f4045f

Please sign in to comment.