Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/unicode/display_width/string_ext.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@

class String
def display_width(ambiguous = nil, overwrite = nil, old_options = {}, **options)
Unicode::DisplayWidth.of(self, ambiguous, overwrite, old_options = {}, **options)
Unicode::DisplayWidth.of(self, ambiguous, overwrite, old_options, **options)
end
end
7 changes: 7 additions & 0 deletions spec/display_width_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
require_relative '../lib/unicode/display_width/string_ext'

describe 'Unicode::DisplayWidth.of' do
it 'forwards positional legacy options from String with the same precedence as .of' do
expect( '·'.display_width(nil, nil, { ambiguous: 2 }) ).to eq 2
expect( '·'.display_width(nil, nil, { ambiguous: 2 }, ambiguous: 1) ).to eq(
Unicode::DisplayWidth.of('·', nil, nil, { ambiguous: 2 }, ambiguous: 1)
)
end

describe '[east asian width]' do
it 'returns 2 for F' do
expect( '!'.display_width ).to eq 2
Expand Down
Loading