From 5342d67fa4eb5ce22e5d40c61a0db6bbb5fc52fd Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Tue, 7 Feb 2017 23:01:23 +0000 Subject: [PATCH] Remove unneeded padding in relative line numbers highlighting We were still adding one more char to the line number width in case it would contain a minus sign. The minus signs are not used anymore in relative line numbering so we dont need to keep that addtional char which is always a blank. --- src/highlighters.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/highlighters.cc b/src/highlighters.cc index dca11ab7b..f5b57c037 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -744,14 +744,14 @@ void show_line_numbers(const Context& context, HighlightFlags flags, ++digit_count; char format[16]; - format_to(format, "%{}d{}", digit_count + (relative ? 1 : 0), separator); - int main_selection = (int)context.selections().main().cursor().line + 1; + format_to(format, "%{}d{}", digit_count, separator); + const int main_line = (int)context.selections().main().cursor().line + 1; for (auto& line : display_buffer.lines()) { const int current_line = (int)line.range().begin.line + 1; - const bool is_cursor_line = main_selection == current_line; + const bool is_cursor_line = main_line == current_line; const int line_to_format = (relative and not is_cursor_line) ? - current_line - main_selection : current_line; + current_line - main_line : current_line; char buffer[16]; snprintf(buffer, 16, format, std::abs(line_to_format)); DisplayAtom atom{buffer};