Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix prompt width calculation bug #695

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/reline/line_editor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ def wrapped_prompt_and_input_lines
next cached
end
*wrapped_prompts, code_line_prompt = split_by_width(prompt, width).first.compact
wrapped_lines = split_by_width(line, width, offset: calculate_width(code_line_prompt)).first.compact
wrapped_lines = split_by_width(line, width, offset: calculate_width(code_line_prompt, true)).first.compact
wrapped_prompts.map { |p| [p, ''] } + [[code_line_prompt, wrapped_lines.first]] + wrapped_lines.drop(1).map { |c| ['', c] }
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/reline/yamatanooroti/multiline_repl
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ opt = OptionParser.new
opt.on('--dynamic-prompt') {
Reline.prompt_proc = proc { |lines|
lines.each_with_index.map { |l, i|
'[%04d]> ' % i
"\e[1m[%04d]>\e[m " % i
}
}
}
Expand Down Expand Up @@ -222,7 +222,7 @@ rescue
end

begin
prompt = ENV['RELINE_TEST_PROMPT'] || 'prompt> '
prompt = ENV['RELINE_TEST_PROMPT'] || "\e[1mprompt>\e[m "
puts 'Multiline REPL.'
while code = Reline.readmultiline(prompt, true) { |code| TerminationChecker.terminated?(code) }
case code.chomp
Expand Down
Loading