File tree Expand file tree Collapse file tree 3 files changed +6
-9
lines changed
Expand file tree Collapse file tree 3 files changed +6
-9
lines changed Original file line number Diff line number Diff line change 1414--- @field last_input_window_position integer[] | nil
1515--- @field last_output_window_position integer[] | nil
1616--- @field last_code_win_before_opencode integer | nil
17- --- @field output_window_at_bottom boolean
1817--- @field current_code_buf number | nil
1918--- @field display_route any | nil
2019--- @field current_mode string
@@ -56,7 +55,6 @@ local _state = {
5655 last_focused_opencode_window = nil ,
5756 last_input_window_position = nil ,
5857 last_output_window_position = nil ,
59- output_window_at_bottom = true ,
6058 last_code_win_before_opencode = nil ,
6159 current_code_buf = nil ,
6260 display_route = nil ,
Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ local config = require('opencode.config')
33
44local M = {}
55M .namespace = vim .api .nvim_create_namespace (' opencode_output' )
6+ M .viewport_at_bottom = true
67
78function M .create_buf ()
89 local output_buf = vim .api .nvim_create_buf (false , true )
@@ -215,7 +216,7 @@ function M.setup_autocmds(windows, group)
215216 buffer = windows .output_buf ,
216217 callback = function ()
217218 -- Update state to track if user is at bottom
218- state . output_window_at_bottom = M .is_at_bottom (windows .output_win )
219+ M . viewport_at_bottom = M .is_at_bottom (windows .output_win )
219220 end ,
220221 })
221222end
@@ -225,6 +226,7 @@ function M.clear()
225226 -- clear extmarks in all namespaces as I've seen RenderMarkdown leave some
226227 -- extmarks behind
227228 M .clear_extmarks (0 , - 1 , true )
229+ M .viewport_at_bottom = true
228230end
229231
230232return M
Original file line number Diff line number Diff line change @@ -51,9 +51,6 @@ function M.reset()
5151 end
5252 state .current_permission = nil
5353
54- -- Reset scroll state when session changes
55- state .output_window_at_bottom = true
56-
5754 trigger_on_data_rendered ()
5855end
5956
@@ -242,16 +239,16 @@ function M.scroll_to_bottom()
242239 if prev_line_count == 0 then
243240 should_scroll = true
244241 -- Scroll if user is at bottom (respects manual scroll position)
245- elseif state . output_window_at_bottom then
242+ elseif output_window . viewport_at_bottom then
246243 should_scroll = true
247244 end
248245
249246 if should_scroll then
250247 vim .api .nvim_win_set_cursor (state .windows .output_win , { line_count , 0 })
251- state . output_window_at_bottom = true
248+ output_window . viewport_at_bottom = true
252249 else
253250 -- User has scrolled up, don't scroll
254- state . output_window_at_bottom = false
251+ output_window . viewport_at_bottom = false
255252 end
256253end
257254
You can’t perform that action at this time.
0 commit comments