@@ -203,26 +203,6 @@ def type
203
203
end
204
204
end
205
205
206
- # A node in the print tree that represents plain content that cannot be broken
207
- # up (by default this assumes strings, but it can really be anything).
208
- class Text
209
- attr_reader :objects , :width
210
-
211
- def initialize
212
- @objects = [ ]
213
- @width = 0
214
- end
215
-
216
- def add ( object : "" , width : object . length )
217
- @objects << object
218
- @width += width
219
- end
220
-
221
- def type
222
- :text
223
- end
224
- end
225
-
226
206
# A node in the print tree that represents trimming all of the indentation of
227
207
# the current line, in the rare case that you need to ignore the indentation
228
208
# that you've already created. This node should be placed after a Breakable.
@@ -508,9 +488,6 @@ def flush(base_indentation = DEFAULT_INDENTATION)
508
488
line_suffixes << [ indent , mode , doc ]
509
489
when :break_parent
510
490
# do nothing
511
- when :text
512
- doc . objects . each { |object | buffer << object }
513
- position += doc . width
514
491
else
515
492
# Special case where the user has defined some way to get an extra doc
516
493
# node that we don't explicitly support into the list. In this case
@@ -614,8 +591,6 @@ def last_position(node)
614
591
width = 0
615
592
when :if_break
616
593
queue = doc . break_contents + queue
617
- when :text
618
- width += doc . width
619
594
end
620
595
end
621
596
@@ -955,9 +930,6 @@ def fits?(next_commands, rest_commands, remaining)
955
930
elsif mode == MODE_FLAT && doc . flat_contents . any?
956
931
commands += doc . flat_contents . reverse . map { |part | [ indent , mode , part ] }
957
932
end
958
- when :text
959
- doc . objects . each { |object | fit_buffer << object }
960
- remaining -= doc . width
961
933
end
962
934
end
963
935
@@ -975,9 +947,7 @@ def reset
975
947
def remove_breaks_with ( doc , replace )
976
948
case doc . type
977
949
when :breakable
978
- text = Text . new
979
- text . add ( object : doc . force? ? replace : doc . separator , width : doc . width )
980
- text
950
+ doc . force? ? replace : doc . separator
981
951
when :if_break
982
952
Align . new ( 0 , doc . flat_contents )
983
953
else
0 commit comments