From 9f36fe2f1ba4e4a16fc7866dd95105674181b8f6 Mon Sep 17 00:00:00 2001 From: Anthony Sottile Date: Sat, 28 Mar 2020 16:56:48 -0700 Subject: [PATCH] Fix highlighting right at the edge of a non-scrolled line --- babi/file.py | 2 +- tests/features/syntax_highlight_test.py | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/babi/file.py b/babi/file.py index 87c0a9c..296b4aa 100644 --- a/babi/file.py +++ b/babi/file.py @@ -805,7 +805,7 @@ class File: else: h_s_x = region.x - l_x - if region.end >= l_x_max: + if region.end >= l_x_max and l_x_max < len(self.buf[l_y]): if file_hl.include_edge: h_e_x = curses.COLS else: diff --git a/tests/features/syntax_highlight_test.py b/tests/features/syntax_highlight_test.py index 0488b96..7208674 100644 --- a/tests/features/syntax_highlight_test.py +++ b/tests/features/syntax_highlight_test.py @@ -113,3 +113,12 @@ def test_syntax_highlighting_one_off_left_of_screen(run, tmpdir): h.press('End') h.await_text_missing('?') h.assert_screen_attr_equals(1, [(236, 40, 0)] * 20) + + +def test_syntax_highlighting_to_edge_of_screen(run, tmpdir): + f = tmpdir.join('f.demo') + f.write(f'# {"x" * 18}') + + with run(str(f), term='screen-256color', width=20) as h, and_exit(h): + h.await_text('# xxx') + h.assert_screen_attr_equals(1, [(243, 40, 0)] * 20)