-
-
Notifications
You must be signed in to change notification settings - Fork 18
fix: fix autoscroll in case of early terminal focus #111
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
igorlfs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey, thanks for looking into this. Made a few important comments.
|
Hi there again, You're right my initial implementation was quite poorly tested, my bad. I've done a more thorough implementation which seems to fix all autoscrolling issues I've been seeing. Most important changes are:
I also spotted a bug, namely that term buffers seem to be re-used, but the autoscroll setup seems to get called on each session restart, causing the There's also no logic for clearing entries in the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for going the extra mile to solve this issue!
Keep track of autoscrolling by individual term buffers
That's a really nice observation by the way!
ffd5030 to
0805d90
Compare
0805d90 to
2b76a80
Compare
|
Hey there, I pushed some small fixes and merged soon after. Let me know if you run into any trouble with this newer version |
* fix: fix autoscroll in case of early terminal focus * refactor: rename scroll functions * feat: more proper autoscroll fix * refactor: remove unused arg and debug log * refactor: add arg type comments * fix(scroll): minor tweaks --------- Co-authored-by: Igor <igorlfs@ufmg.br>
|
Hi there, I'm having issues where opening the termbuf after lines have appeared causes the autoscroll to not work, as in it's stuck to the top. I had this issue in my PR, and moving the I.e.: ---@param winnr integer
---@param bufnr integer
M.scroll_to_bottom = function(winnr, bufnr)
if util.is_win_valid(winnr) and util.is_buf_valid(bufnr) then
vim.schedule(function()
api.nvim_win_set_cursor(winnr, { api.nvim_buf_line_count(bufnr), 0 })
end)
termbuf_is_autoscrolling[bufnr] = true
end
endNot familiar enough with nvim internals to understand exactly what the root cause is here, but the above code (and removing vim.schedule from the |
Can you share an exact repro? EDIT: I guess you're using a snippet similar to this one, with an early focus... I can actually repro with such a setup. I'll push your suggestion, because I see no reason not to. But I'm not 100% sure that's the way forward, with no regressions. |
|
Done with 76f219c |
Fixes an issue where the
CursorMovedautocmd will run before theon_lineshandler and setautoscroll = falsein the case of the user focusing on the terminal before any output, resulting in broken autoscrolling.Discussion: #109 (reply in thread)