Sfoglia il codice sorgente

LibGUI: Make folded lines take up 0 vertical space in no-wrap mode

If a line is hidden by a folding region, then it needs to not take up
any vertical space, or else we just get a glitchy blank line instead of
a folded one. This change corrects the logic when wrapping is not
enabled.
Sam Atkins 2 anni fa
parent
commit
9d2027de6b
1 ha cambiato i file con 2 aggiunte e 4 eliminazioni
  1. 2 4
      Userland/Libraries/LibGUI/TextEditor.cpp

+ 2 - 4
Userland/Libraries/LibGUI/TextEditor.cpp

@@ -2167,10 +2167,8 @@ void TextEditor::recompute_visual_lines(size_t line_index, Vector<TextDocumentFo
         }
     }
 
-    if (is_wrapping_enabled())
-        visual_data->visual_rect = { m_horizontal_content_padding, 0, available_width, static_cast<int>(visual_data->visual_lines.size()) * line_height() };
-    else
-        visual_data->visual_rect = { m_horizontal_content_padding, 0, text_width_for_font(line.view(), font()), line_height() };
+    auto line_width = is_wrapping_enabled() ? available_width : text_width_for_font(line.view(), font());
+    visual_data->visual_rect = { m_horizontal_content_padding, 0, line_width, static_cast<int>(visual_data->visual_lines.size()) * line_height() };
 }
 
 template<typename Callback>