LibGUI: Grow the "line content rect" slightly in single line text boxes

Previously we would sometimes leave some pixels from an old selection
rect on screen after clearing the selection. It was because the line
content rect was smaller than the visual selection rect, and we were
using the line content rect for invalidations.
This commit is contained in:
Andreas Kling 2020-05-18 16:46:13 +02:00
parent 22cd861c7e
commit 558ca65ca5
Notes: sideshowbarker 2024-07-19 06:29:48 +09:00

View file

@ -1031,7 +1031,7 @@ Gfx::Rect TextEditor::line_content_rect(size_t line_index) const
{
auto& line = this->line(line_index);
if (is_single_line()) {
Gfx::Rect line_rect = { content_x_for_position({ line_index, 0 }), 0, font().width(line.view()), font().glyph_height() + 2 };
Gfx::Rect line_rect = { content_x_for_position({ line_index, 0 }), 0, font().width(line.view()), font().glyph_height() + 4 };
line_rect.center_vertically_within({ {}, frame_inner_rect().size() });
return line_rect;
}