Skip to content

Commit 76f219c

Browse files
committed
fix(scroll): handle autoscroll in case of early terminal focus
See #111 (comment)
1 parent 85b9150 commit 76f219c

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lua/dap-view/console/scroll.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ M.setup_autoscroll = function(bufnr)
4747
if api.nvim_get_current_buf() == bufnr then
4848
-- Ensure the cursor movement happens in the main event loop
4949
-- Otherwise the call may happen too early
50-
vim.schedule(function()
51-
M.scroll_to_bottom(winnr, bufnr)
52-
end)
50+
M.scroll_to_bottom(winnr, bufnr)
5351
end
5452
end)
5553
end
@@ -67,7 +65,9 @@ end
6765
---@param bufnr integer
6866
M.scroll_to_bottom = function(winnr, bufnr)
6967
if util.is_win_valid(winnr) and util.is_buf_valid(bufnr) then
70-
api.nvim_win_set_cursor(winnr, { api.nvim_buf_line_count(bufnr), 0 })
68+
vim.schedule(function()
69+
api.nvim_win_set_cursor(winnr, { api.nvim_buf_line_count(bufnr), 0 })
70+
end)
7171

7272
termbuf_is_autoscrolling[bufnr] = true
7373
end

0 commit comments

Comments
 (0)