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()