Skip to content

Render differential updates by named segments instead of array index#913

Open
tompng wants to merge 2 commits into
ruby:masterfrom
tompng:named_segments_render
Open

Render differential updates by named segments instead of array index#913
tompng wants to merge 2 commits into
ruby:masterfrom
tompng:named_segments_render

Conversation

@tompng

@tompng tompng commented Jul 26, 2026

Copy link
Copy Markdown
Member

Summary

render_line_differential matches the segments of each rendered line between the previous and the current frame to compute a minimal screen update. This matching used to be positional: a line was an array of [x, width, content] tuples where the array index doubled as the segment's identity (index 0 = prompt, 1 = input line, 2 = rprompt, 3.. = dialogs). Keeping identities stable required nil-padding and magic index offsets like dialog_rows[index + 3] = ..., which is fragile and hard to extend when adding a new kind of segment.

This PR gives each segment an explicit identifier and changes the tuple to [identifier, x, width, content]:

  • Built-in segments: :builtin_prompt, :builtin_line, :builtin_rprompt, :builtin_menu
  • Dialogs: :"dialog_#{dialog.name}" — the dialog_ prefix isolates user-provided dialog names from the builtin identifiers and from the internal markers (:skip, :blank, :outdated)

Idea for the future

I have an idea to add a completion preview if there is only one candidate, or there's a common prefix.
This PR will be a preparation for such change.

@tompng tompng changed the title Named segments render Render differential updates by named segments instead of array index Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant