Skip to content

Separate prompt and input line in rendering - #652

Merged
ima1zumi merged 2 commits into
ruby:masterfrom
tompng:split_prompt_line_render
Apr 23, 2024
Merged

ima1zumi merged 2 commits into
ruby:masterfrom
tompng:split_prompt_line_render

Conversation

@tompng

@tompng tompng commented Mar 19, 2024

Copy link
Copy Markdown
Member

Split prompt and input_line passed to render_line_differential.
This will improve differential rendering performance in these cases

  • prompt changed but input_line is not changed
  • input_line changed but prompt is not changed

To separately render prompt and input_line, line items passed to render_line_differential is changed

# before
[[0, 12, "prompt> code"], [13, 7, "Dialog1"]]
# after
[[0, 8, "prompt> "], [8, 4, "code"], [13, 7, "Dialog1"]]

@tompng
tompng force-pushed the split_prompt_line_render branch 2 times, most recently from ddca9a3 to c2d49e1 Compare March 26, 2024 02:30
Often, only one of prompt and input changes.
Split prompt+input_line to a separate rendering item will improve differential rendering performance.
@tompng
tompng force-pushed the split_prompt_line_render branch from c2d49e1 to f0f734d Compare April 16, 2024 14:38
Comment thread lib/reline/line_editor.rb Outdated
end

def wrapped_lines
def wrapped_prompt_lines

@ima1zumi ima1zumi Apr 18, 2024 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about naming it wrapped_prompt_and_lines or wrapped_prompt_and_input_lines? This would make it clear that prompts and lines are returned separately.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrapped_prompt_and_input_lines looks good, thanks!
updated

@ima1zumi ima1zumi left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🌟

@ima1zumi
ima1zumi merged commit 16d82f1 into ruby:master Apr 23, 2024
matzbot pushed a commit to ruby/ruby that referenced this pull request Apr 23, 2024
(ruby/reline#652)

* Separate prompt and input line in rendering

Often, only one of prompt and input changes.
Split prompt+input_line to a separate rendering item will improve differential rendering performance.

* Rename method wrapped_prompt_lines to more descriptive name

ruby/reline@16d82f1f23
@tompng
tompng deleted the split_prompt_line_render branch April 23, 2024 15:04
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.

2 participants