From 3b8181fa029d282770091a16c784916c9c8548cf Mon Sep 17 00:00:00 2001 From: Mark Rogalski Date: Mon, 16 May 2016 21:21:54 +0200 Subject: Add comment with line num implementation rationale --- ranger/gui/widgets/browsercolumn.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/ranger/gui/widgets/browsercolumn.py b/ranger/gui/widgets/browsercolumn.py index 1dd4aef8..56b5da78 100644 --- a/ranger/gui/widgets/browsercolumn.py +++ b/ranger/gui/widgets/browsercolumn.py @@ -290,7 +290,17 @@ class BrowserColumn(Pager): self.fm.do_cut, current_linemode.name, metakey, active_pane, self.settings.line_numbers) + # Check if current line has not already computed and cached if key in drawn.display_data: + # This conditional is necessary for two things: + # 1) computing relative line numbers, + # 2) switching between relative line numbers and normal. + # + # (1) is necessary because drawn.display_data cache cannot be + # trusted when it comes to line numbers. + # For (2) we could add self.settings.relative_line_numbers to + # key, but we still require a conditional check here for (1), + # and it solves both problems at the same time. if self.main_column and self.settings.line_numbers: line_number_text = self._format_line_number(linum_format, i, -- cgit 1.4.1-2-gfad0