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

Correct padding space calculation #388

Merged
merged 1 commit into from
Nov 21, 2021

Conversation

ima1zumi
Copy link
Member

fix ruby/irb#308

This bug occurred when dialog.width - calculate_width(s, true) was negative.

When dialog.width is shorter than old_dialog.width, it calculates how much padding it has to do. However, there are cases where s is longer than dialog.width, as in the issue. In that case, padding_space_with_escape_sequences will crash.

Here, old_dialog.width is longer than dialog.width, so I changed the padding width to old_dialog.width - dialog.width.

fix ruby/irb#308

This bug occurred when `dialog.width - calculate_width(s, true)` was negative.

When `dialog.width` is shorter than `old_dialog.width`, it calculates how much padding it has to do. However, there are cases where `s` is longer than `dialog.width`, as in the issue. In that case, `padding_space_with_escape_sequences` will crash.

Here, `old_dialog.width` is longer than `dialog.width`, so I changed the padding width to `old_dialog.width - dialog.width`.
@gotoken
Copy link
Member

gotoken commented Nov 20, 2021

looks good to me

@gotoken gotoken merged commit 3cfd620 into ruby:master Nov 21, 2021
@ima1zumi ima1zumi deleted the fix-calc-padding-width branch November 21, 2021 06:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

IRB crashes by completion on the first line before long line
2 participants