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.
If the unit test fails, it prints out the input twice instead of the expected value.
BTW I was having a look at the
runeSliceWidthRange
function because @raslop was working on this in #1029. Unfortunately the current implementation in the master branch does appear to be slightly buggy if you consider the following test cases:In particular the current implementation panics when the beginning and end indexes are the same and happen to be in the middle of a rune, and also the case where the end occurs after the start of the last rune isn't handled properly. The following is a more robust implementation that does handle the above cases in addition to the existing cases:
That being said,
runeSliceWidthRange
is currently called in only a few places when truncating long filenames, and for these cases the filename input is sufficiently long so these edge cases don't matter, so I can understand if you don't want to make any changes to the existing code.Anyway the suggestion about
runeSliceWidthRange
is a separate thing, and can be addressed later if at all. At the very least the change for correcting the test case error reporting should be merged.