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.
This commit is contained in:
Sam Atkins 2023-07-19 20:34:32 +01:00 committed by Sam Atkins
parent d832f3a887
commit 9d2027de6b

View file

@ -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>