Skip to content

Fix pasting tab-indented code crash - #630

Merged
tompng merged 1 commit into
ruby:masterfrom
tompng:fix_tab_complete_at_beg
Jan 4, 2024
Merged

tompng merged 1 commit into
ruby:masterfrom
tompng:fix_tab_complete_at_beg

Conversation

@tompng

@tompng tompng commented Jan 3, 2024 •

Copy link
Copy Markdown
Member

When you paste code below that is indented with tab, Reline crashes.

2.times do
	puts
	puts
end

Reproduce

It happens when completion candidates of autocomplete at the beginning of the line is empty.
Example: With irb --type-completor or with ruby/irb:master that disabled empty target completion.

Comment thread lib/reline/line_editor.rb
if not just_show_list and target < completed
@line = (preposing + completed + completion_append_character.to_s + postposing).split("\n")[@line_index] || String.new(encoding: @encoding)
line_to_pointer = (preposing + completed + completion_append_character.to_s).split("\n").last || String.new(encoding: @encoding)
line_to_pointer = (preposing + completed + completion_append_character.to_s).split("\n")[@line_index] || String.new(encoding: @encoding)

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.

I think this is not causing a bug because there is a guard clause return if completed.nil? in line 1302.

@st0012 st0012 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.

Thanks for the fix 👍

@st0012 st0012 added the bug Something isn't working label Jan 4, 2024
@tompng
tompng merged commit 90155fd into ruby:master Jan 4, 2024
@tompng
tompng deleted the fix_tab_complete_at_beg branch January 4, 2024 11:57
@st0012 st0012 mentioned this pull request Jan 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants