Repository navigation
Refactor Reline::Unicode ed_ vi_ em_ methods - #720
Merged
Merged
Conversation
tompng
force-pushed
the
unicode_edit_func_refactor
branch
2 times, most recently
from
June 10, 2024 13:59
789d090 to
85f4405
Compare
st0012
reviewed
Jun 17, 2024
st0012
reviewed
Jun 17, 2024
| end | ||
| [byte_size, width, new_str] | ||
| gcs = line.byteslice(byte_pointer..).grapheme_clusters | ||
| nonwords = gcs.take_while { |c| c.encode(Encoding::UTF_8).match?(/\P{Word}/) } |
Member
There was a problem hiding this comment.
Does it make sense to encode gcs all at once before looping through them?
Also, all tests still pass even if I removed these encoding calls. Can we add a few cases for them?
Member
Author
There was a problem hiding this comment.
encode will change bytesize, so I have to fix all encode(Encoding::UTF_8).grapheme_clusters in this file to return the correct bytesize in original encoding. I'll also add a test.
tompng
marked this pull request as draft
June 17, 2024 16:13
tompng
marked this pull request as ready for review
June 19, 2024 16:08
tompng
force-pushed
the
unicode_edit_func_refactor
branch
from
October 9, 2024 16:17
2f519c3 to
3365ab0
Compare
tompng
marked this pull request as draft
October 9, 2024 16:18
tompng
force-pushed
the
unicode_edit_func_refactor
branch
from
November 12, 2024 16:57
3365ab0 to
e699b4f
Compare
tompng
force-pushed
the
unicode_edit_func_refactor
branch
from
November 13, 2024 10:31
e699b4f to
2ad27a7
Compare
tompng
marked this pull request as ready for review
November 13, 2024 14:13
matzbot
pushed a commit
to ruby/ruby
that referenced
this pull request
Dec 15, 2024
(ruby/reline#720) * Refactor Reline::Unicode vi_ ed_ em_ methods * Make Reline::Unicode's vi_ ed_ em_ method encoding safe ruby/reline@cdd7288978
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depend on #759 (split some commits to it)
Refactor Reline::Unicode vi_ ed_ em_ methods
Rewrite them with about -250 lines.
Update questionable test case.
Description of refactor
Using get_prev_mbchar_size and get_next_mbchar_size in a
whileloop is extreamly inefficient.Using
take_whileto an array of grapheme_cluster is simple and fast enough.Performance
Scenario: paste 2KB text
aaaaa...aaaaato IRB and press OPTION+LEFT.