Explorar o código

LibGfx: Treat "\r\n" as a single line break during text layout

We currently insert two line breaks for this sequence. This Windows-
style of line breaking can be seen in documents on the web.
Timothy Flynn hai 1 ano
pai
achega
d9349f1510
Modificáronse 1 ficheiros con 5 adicións e 2 borrados
  1. 5 2
      Userland/Libraries/LibGfx/TextLayout.cpp

+ 5 - 2
Userland/Libraries/LibGfx/TextLayout.cpp

@@ -73,8 +73,11 @@ Vector<ByteString, 32> TextLayout::wrap_lines(TextElision elision, TextWrapping
 
             continue;
         }
-        case '\n':
-        case '\r': {
+        case '\r':
+            if (it.peek(1) == static_cast<u32>('\n'))
+                ++it;
+            [[fallthrough]];
+        case '\n': {
             if (current_block_type.has_value()) {
                 blocks.append({
                     current_block_type.value(),