@@ -10,6 +10,7 @@ local M = {}
1010M ._subscriptions = {}
1111M ._prev_line_count = 0
1212M ._render_state = RenderState .new ()
13+ M ._disable_auto_scroll = false
1314
1415local trigger_on_data_rendered = require (' opencode.util' ).debounce (function ()
1516 local cb_type = type (config .ui .on_data_rendered )
@@ -31,6 +32,7 @@ end, 250)
3132function M .reset ()
3233 M ._prev_line_count = 0
3334 M ._render_state :reset ()
35+ M ._disable_auto_scroll = false
3436
3537 output_window .clear ()
3638
114116
115117function M ._render_full_session_data (session_data )
116118 M .reset ()
119+
120+ -- disable auto-scroll, makes loading a full session much faster
121+ M ._disable_auto_scroll = true
122+
117123 local revert_index = nil
118124
119125 for i , msg in ipairs (session_data ) do
@@ -134,6 +140,9 @@ function M._render_full_session_data(session_data)
134140 if revert_index then
135141 M ._write_formatted_data (formatter ._format_revert_message (state .messages , revert_index ))
136142 end
143+
144+ -- re-enable Auto-scroll
145+ M ._disable_auto_scroll = false
137146 M ._scroll_to_bottom ()
138147end
139148
161170--- Auto-scroll to bottom if user was already at bottom
162171--- Respects cursor position if user has scrolled up
163172function M ._scroll_to_bottom ()
173+ -- if we're loading a full session, don't scroll incrementally
174+ if M ._disable_auto_scroll then
175+ return
176+ end
177+
164178 local ok , line_count = pcall (vim .api .nvim_buf_line_count , state .windows .output_buf )
165179 if not ok then
166180 return
0 commit comments