From 11268ffa166d7ca40df18bbea699aae667bb0727 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 23 Mar 2021 10:04:58 +0530 Subject: [PATCH] Fix marking of text not working on lines that contain zero cells Zero cells are passed to the regex engine as spaces, so they must increment the match_pos counter. Fixes #3403 --- docs/changelog.rst | 3 +++ kitty/line.c | 2 +- kitty_tests/screen.py | 7 +++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/docs/changelog.rst b/docs/changelog.rst index c22197e47..a75930980 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -105,6 +105,9 @@ To update |kitty|, :doc:`follow the instructions `. - Graphics protocol: Add a control to allow clients to specify that the cursor should not move when displaying an image (:iss:`3411`) +- Fix marking of text not working on lines that contain zero cells + (:iss:`3403`) + 0.19.3 [2020-12-19] ------------------- diff --git a/kitty/line.c b/kitty/line.c index 9dc8b3305..5b84a8e14 100644 --- a/kitty/line.c +++ b/kitty/line.c @@ -736,8 +736,8 @@ apply_mark(Line *line, const attrs_type mark, index_type *cell_pos, unsigned int #define MARK { line->gpu_cells[x].attrs &= ATTRS_MASK_WITHOUT_MARK; line->gpu_cells[x].attrs |= mark; } index_type x = *cell_pos; MARK; + (*match_pos)++; if (line->cpu_cells[x].ch) { - (*match_pos)++; if (line->cpu_cells[x].ch == '\t') { unsigned num_cells_to_skip_for_tab = line->cpu_cells[x].cc_idx[0]; while (num_cells_to_skip_for_tab && x + 1 < line->xnum && line->cpu_cells[x+1].ch == ' ') { diff --git a/kitty_tests/screen.py b/kitty_tests/screen.py index 9784dad83..aba670cc9 100644 --- a/kitty_tests/screen.py +++ b/kitty_tests/screen.py @@ -647,6 +647,13 @@ class TestScreen(BaseTest): self.ae(s.marked_cells(), cells(8)) s.set_marker(marker_from_regex('\t', 3)) self.ae(s.marked_cells(), cells(*range(8))) + s = self.create_screen() + s.cursor.x = 2 + s.draw('x') + s.cursor.x += 1 + s.draw('x') + s.set_marker(marker_from_function(mark_x)) + self.ae(s.marked_cells(), [(2, 0, 1), (4, 0, 2)]) def test_hyperlinks(self): s = self.create_screen()