Skip to content

Commit ebef0ec

Browse files
committed
fix(renderer): shift render_state and drop part_folds on remove
fix(renderer): shift siblings on in-place upsert_part_now size change fix(renderer): shift siblings on append_part_now fix(renderer): drop redundant shift_all around render_state mutators
1 parent e55f7d3 commit ebef0ec

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

lua/opencode/ui/renderer/buffer.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,9 @@ function M.upsert_part_now(part_id, message_id, formatted_data, previous_formatt
480480
apply_part_render_data(part_id, formatted_data, cached.line_start)
481481

482482
if new_line_end ~= cached.line_end then
483+
local delta = new_line_end - old_line_end
483484
ctx.render_state:update_part_lines(part_id, cached.line_start, new_line_end)
485+
output_window.shift_folds(old_line_end + 1, delta)
484486
end
485487
apply_extmarks(previous_formatted, formatted_data, cached.line_start, old_line_end, new_line_end, prefix_len, true)
486488

@@ -622,6 +624,7 @@ function M.append_part_now(part_id, extra_lines, extra_extmarks, previous_format
622624

623625
local new_line_end = cached.line_end + #extra_lines
624626
ctx.render_state:update_part_lines(part_id, cached.line_start, new_line_end)
627+
output_window.shift_folds(insert_at, #extra_lines)
625628

626629
local formatted_data = ctx.formatted_parts[part_id]
627630
if formatted_data then
@@ -657,6 +660,7 @@ function M.remove_part_now(part_id)
657660
local cached = ctx.render_state:get_part(part_id)
658661
if not cached or not cached.line_start or not cached.line_end then
659662
ctx.render_state:remove_part(part_id)
663+
ctx.part_folds[part_id] = nil
660664
return
661665
end
662666

@@ -665,6 +669,7 @@ function M.remove_part_now(part_id)
665669
local delta = -(cached.line_end - cached.line_start + 1)
666670
output_window.shift_folds(cached.line_start, delta)
667671
ctx.render_state:remove_part(part_id)
672+
ctx.part_folds[part_id] = nil
668673
end
669674

670675
---@param message_id string

0 commit comments

Comments
 (0)