about summary refs log tree commit diff stats
path: root/ranger
diff options
context:
space:
mode:
authortoonn <toonn@toonn.io>2022-05-27 13:57:58 +0200
committertoonn <toonn@toonn.io>2022-05-27 13:57:58 +0200
commit72dab6555185ce92e3fb50e7f857f981cc1a7f83 (patch)
tree982e4daf2d06b052713138f47b969917e03e5c57 /ranger
parent2fbf622751e7abd97ba4843623eb549dfa789c31 (diff)
downloadranger-72dab6555185ce92e3fb50e7f857f981cc1a7f83.tar.gz
browsercolumn: Take into account one_indexed setting
Line number width calculation was ignoring the one_indexed setting. This
meant recalculating the width one line too late.
Diffstat (limited to 'ranger')
-rw-r--r--ranger/gui/widgets/browsercolumn.py7
1 files changed, 5 insertions, 2 deletions
diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py
index 4867d184..305b8284 100644
--- a/ranger/gui/widgets/browsercolumn.py
+++ b/ranger/gui/widgets/browsercolumn.py
@@ -283,14 +283,17 @@ class BrowserColumn(Pager):  # pylint: disable=too-many-instance-attributes
         scroll_end = self.scroll_begin + self.hei - 1
         distance_to_top = selected_i - self.scroll_begin
         distance_to_bottom = scroll_end - selected_i
+        one_indexed_offset = 1 if self.settings.one_indexed else 0
 
         if self.settings.line_numbers.lower() == "relative":
             linum_text_len = nr_of_digits(max(distance_to_top,
                                               distance_to_bottom))
             if not self.settings.relative_current_zero:
-                linum_text_len = max(nr_of_digits(selected_i), linum_text_len)
+                linum_text_len = max(nr_of_digits(selected_i
+                                                  + one_indexed_offset),
+                                     linum_text_len)
         else:
-            linum_text_len = nr_of_digits(scroll_end)
+            linum_text_len = nr_of_digits(scroll_end + one_indexed_offset)
         linum_format = "{0:>" + str(linum_text_len) + "}"
 
         for line in range(self.hei):