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 invalid byte sequence in autoindent calculation #631

Closed
wants to merge 1 commit into from

Conversation

tompng
Copy link
Member

@tompng tompng commented Jul 4, 2023

Workaround for #627

The root cause of this issue is several (more than two) bugs in Reline.
ruby/reline#553

Reline sometimes passes wrong byte_pointer to auto_indent_proc.
If Reline's bug is not going to be fixed soon, IRB needs to validate encoding of byteslice(0, byte_pointer) before using it.

Copy link
Member

@st0012 st0012 left a comment

Choose a reason for hiding this comment

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

LGTM, just once question

@@ -33,7 +33,7 @@ def teardown
def calculate_indenting(lines, add_new_line)
lines = lines + [""] if add_new_line
last_line_index = lines.length - 1
byte_pointer = lines.last.length
byte_pointer = lines.last.bytesize
Copy link
Member

Choose a reason for hiding this comment

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

The test seems to capture the issue even without this change?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. This change don't affect the added test. I just fixed it because I found it doing wrong with byte_pointer.

@st0012 st0012 added the bug Something isn't working label Jul 4, 2023
@tompng
Copy link
Member Author

tompng commented Jul 5, 2023

I think ruby/reline#562 will also fix this problem.

@tompng
Copy link
Member Author

tompng commented Jul 8, 2023

Closing this because this pull request is a workaround, and it's fixed in Reline 0.3.6

@tompng tompng closed this Jul 8, 2023
@tompng tompng deleted the fix_autoindent_invalid_byte_seq branch July 8, 2023 12:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

2 participants