diff --git a/src/highlighters.cc b/src/highlighters.cc index 9e0b1313..2d34a55c 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -650,8 +650,14 @@ HighlighterAndId create_column_highlighter(HighlighterParameters params) ColumnCount last_buffer_col = context.window().position().column; for (auto& atom : line) { - if (atom.has_buffer_range() and atom.begin() != atom.end()) - last_buffer_col = get_column(buffer, tabstop, atom.end()); + if (atom.has_buffer_range()) + { + auto pos = atom.end(); + if (pos.column == 0) + pos = {pos.line-1, buffer[pos.line-1].length()}; + if (pos != atom.begin()) + last_buffer_col = get_column(buffer, tabstop, pos); + } } ColumnCount count = column - last_buffer_col; diff --git a/src/window.cc b/src/window.cc index 5b75c147..e3630ad8 100644 --- a/src/window.cc +++ b/src/window.cc @@ -132,11 +132,11 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context) if (buffer_line >= buffer().line_count()) break; auto beg_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column}); - auto end_byte = setup.full_lines ? - buffer()[buffer_line].length() : - get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column}); + auto end_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column}); + auto end_coord = setup.full_lines or end_byte == buffer()[buffer_line].length() ? + buffer_line+1 : BufferCoord{buffer_line, end_byte}; - lines.emplace_back(AtomList{ {buffer(), {buffer_line, beg_byte}, {buffer_line, end_byte}} }); + lines.emplace_back(AtomList{ {buffer(), {buffer_line, beg_byte}, end_coord} }); } m_display_buffer.compute_range(); diff --git a/test/regression/1435-misplaced-cursor-with-show_matching-hl/cmd b/test/regression/1435-misplaced-cursor-with-show_matching-hl/cmd new file mode 100644 index 00000000..61d2be16 --- /dev/null +++ b/test/regression/1435-misplaced-cursor-with-show_matching-hl/cmd @@ -0,0 +1 @@ +O diff --git a/test/regression/1435-misplaced-cursor-with-show_matching-hl/display b/test/regression/1435-misplaced-cursor-with-show_matching-hl/display new file mode 100644 index 00000000..9e3a766b --- /dev/null +++ b/test/regression/1435-misplaced-cursor-with-show_matching-hl/display @@ -0,0 +1,12 @@ +{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "·" }, { "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": "¬" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "¬" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] } +{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] } +{ "jsonrpc": "2.0", "method": "info_hide", "params": [] } +{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "out 1:2 " }, { "face": { "fg": "black", "bg": "yellow", "attributes": [] }, "contents": "[+]" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "yellow", "bg": "default", "attributes": [] }, "contents": "insert " }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " - unnamed0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "attributes": [] }] } +{ "jsonrpc": "2.0", "method": "set_cursor", "params": ["buffer", { "line": 0, "column": 1 }] } +{ "jsonrpc": "2.0", "method": "refresh", "params": [true] } +{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "white", "attributes": [] }, "contents": "·" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "¬" }], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "¬" }]], { "fg": "default", "bg": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "attributes": [] }] } +{ "jsonrpc": "2.0", "method": "menu_hide", "params": [] } +{ "jsonrpc": "2.0", "method": "info_hide", "params": [] } +{ "jsonrpc": "2.0", "method": "draw_status", "params": [[], [{ "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": "out 1:1 " }, { "face": { "fg": "black", "bg": "yellow", "attributes": [] }, "contents": "[+]" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " " }, { "face": { "fg": "blue", "bg": "default", "attributes": [] }, "contents": "1 sel" }, { "face": { "fg": "default", "bg": "default", "attributes": [] }, "contents": " - unnamed0@[kak-tests]" }], { "fg": "cyan", "bg": "default", "attributes": [] }] } +{ "jsonrpc": "2.0", "method": "set_cursor", "params": ["buffer", { "line": 0, "column": 0 }] } +{ "jsonrpc": "2.0", "method": "refresh", "params": [true] } diff --git a/test/regression/1435-misplaced-cursor-with-show_matching-hl/in b/test/regression/1435-misplaced-cursor-with-show_matching-hl/in new file mode 100644 index 00000000..8b137891 --- /dev/null +++ b/test/regression/1435-misplaced-cursor-with-show_matching-hl/in @@ -0,0 +1 @@ + diff --git a/test/regression/1435-misplaced-cursor-with-show_matching-hl/rc b/test/regression/1435-misplaced-cursor-with-show_matching-hl/rc new file mode 100644 index 00000000..a0c5ad74 --- /dev/null +++ b/test/regression/1435-misplaced-cursor-with-show_matching-hl/rc @@ -0,0 +1 @@ +add-highlighter show_whitespaces