From dd90325c02c7a886fdeb454f085e0f064fd0f405 Mon Sep 17 00:00:00 2001 From: AnmiTaliDev Date: Thu, 9 Jul 2026 14:53:20 +0500 Subject: [PATCH] fix: Highlight only the gutter digit Keep the reverse-video current-line marker on the line number itself instead of covering its padding and separator space. Closes #8 --- src/render.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/render.c b/src/render.c index b73e30e..23265a4 100644 --- a/src/render.c +++ b/src/render.c @@ -77,18 +77,26 @@ static const char *prompt_label(editor_mode_t mode) static void render_gutter(abuf_t *ab, const editor_t *ed, size_t file_row, bool is_current) { int width = editor_gutter_width(ed); - char num[32]; - int n = snprintf(num, sizeof(num), "%*zu ", width - 1, file_row + 1); - if (n < 0) { - n = 0; + char digits[32]; + int digit_len = snprintf(digits, sizeof(digits), "%zu", file_row + 1); + if (digit_len < 0) { + digit_len = 0; } + + int pad = width - 1 - digit_len; + for (int i = 0; i < pad; i++) { + abuf_append(ab, " ", 1); + } + if (is_current) { abuf_append_str(ab, "\x1b[7m"); } - abuf_append(ab, num, (size_t)n); + abuf_append(ab, digits, (size_t)digit_len); if (is_current) { abuf_append_str(ab, "\x1b[27m"); } + + abuf_append(ab, " ", 1); } static void render_empty_gutter(abuf_t *ab, const editor_t *ed)