summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGUI/TextEditor.cpp
diff options
context:
space:
mode:
authorLucas CHOLLET <lucas.chollet@free.fr>2022-04-24 19:03:17 +0200
committerAndreas Kling <kling@serenityos.org>2022-04-25 10:46:58 +0200
commit86d4b7ebfcaa86590522a4187ff51a467ef27008 (patch)
treed19642a0c273222fa1ffb4ec5868493186664b22 /Userland/Libraries/LibGUI/TextEditor.cpp
parent4c027efc019493f189451ac954036d736a4b0b97 (diff)
downloadserenity-86d4b7ebfcaa86590522a4187ff51a467ef27008.zip
LibGUI: Display line number next to the first visual line
The number was previously vertically centered, but it prevents from quickly seeing a line change.
Diffstat (limited to 'Userland/Libraries/LibGUI/TextEditor.cpp')
-rw-r--r--Userland/Libraries/LibGUI/TextEditor.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/Userland/Libraries/LibGUI/TextEditor.cpp b/Userland/Libraries/LibGUI/TextEditor.cpp
index 5e4ef18e4b..21675f7f34 100644
--- a/Userland/Libraries/LibGUI/TextEditor.cpp
+++ b/Userland/Libraries/LibGUI/TextEditor.cpp
@@ -466,6 +466,10 @@ void TextEditor::paint_event(PaintEvent& event)
for (size_t i = first_visible_line; i <= last_visible_line; ++i) {
bool is_current_line = i == m_cursor.line();
auto ruler_line_rect = ruler_content_rect(i);
+ // NOTE: Shrink the rectangle to be only on the first visual line.
+ auto const line_height = font().preferred_line_height();
+ if (ruler_line_rect.height() > line_height)
+ ruler_line_rect.set_height(line_height);
// NOTE: Use Painter::draw_text() directly here, as we want to always draw the line numbers in clear text.
painter.draw_text(
ruler_line_rect.shrunken(2, 0),