+ if (!tail.empty()) {
+ // Avoid having a last empty element. This happens when
+ // breaking at the trailing space of string
+ if (tail.back().str.empty())
+ tail.pop_back();
+ else {
+ // Copy the after flags of the original element to the last one.
+ tail.back().row_flags &= ~BreakAfter;
+ tail.back().row_flags |= row_flags & AfterFlags;
+ }
+ // first_e row should be broken after the original element
+ first_e.row_flags |= BreakAfter;
+ } else {
+#if 1
+ // remove the BreakAfter that got added above.
+ first_e.row_flags &= ~BreakAfter;
+#else
+ // FIXME : the code below looks like a good idea, but I do not
+ // have a use case yet. The question is what happens
+ // when breaking at the end of a string with a
+ // trailing space.
+ // if it turns out that no breaking was necessary, remove the
+ // BreakAfter that got added above.
+ if (first_e.dim.wid <= width)
+ first_e.row_flags &= ~BreakAfter;
+#endif
+ // Restore the after flags of the original element.
+ first_e.row_flags |= row_flags & AfterFlags;
+ }