Skip to content

Commit

Permalink
[Fix ctran#675] Correct indentation for double-byte characters (ctran…
Browse files Browse the repository at this point in the history
  • Loading branch information
sashabelozerov authored and vfonic committed May 8, 2020
1 parent 56ba9aa commit d03b9f5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion lib/annotate/annotate_models.rb
Original file line number Diff line number Diff line change
Expand Up @@ -920,7 +920,7 @@ def format_default(col_name, max_size, col_type, bare_type_allowance, attrs)
end

def width(string)
string.chars.inject(0) { |acc, elem| acc + (elem.bytesize == 1 ? 1 : 2) }
string.chars.inject(0) { |acc, elem| acc + (elem.bytesize == 3 ? 2 : 1) }
end

def mb_chars_ljust(string, length)
Expand Down
18 changes: 12 additions & 6 deletions spec/lib/annotate/annotate_models_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1006,6 +1006,9 @@ def self.when_called_with(options = {})
[:active, :boolean, { limit: 1, comment: 'ACTIVE' }],
[:name, :string, { limit: 50, comment: 'NAME' }],
[:notes, :text, { limit: 55, comment: 'NOTES' }],
[:cyrillic, :text, { limit: 30, comment: 'Кириллица' }],
[:japanese, :text, { limit: 60, comment: '熊本大学 イタリア 宝島' }],
[:arabic, :text, { limit: 20, comment: 'لغة' }],
[:no_comment, :text, { limit: 20, comment: nil }],
[:location, :geometry_collection, { limit: nil, comment: nil }]
]
Expand All @@ -1017,12 +1020,15 @@ def self.when_called_with(options = {})
#
# Table name: users
#
# id(ID) :integer not null, primary key
# active(ACTIVE) :boolean not null
# name(NAME) :string(50) not null
# notes(NOTES) :text(55) not null
# no_comment :text(20) not null
# location :geometry_collect not null
# id(ID) :integer not null, primary key
# active(ACTIVE) :boolean not null
# name(NAME) :string(50) not null
# notes(NOTES) :text(55) not null
# cyrillic(Кириллица) :text(30) not null
# japanese(熊本大学 イタリア 宝島) :text(60) not null
# arabic(لغة) :text(20) not null
# no_comment :text(20) not null
# location :geometry_collect not null
#
EOS

Expand Down

0 comments on commit d03b9f5

Please sign in to comment.