diff options
| author | Maxime Coste <mawww@kakoune.org> | 2017-06-15 16:46:24 +0100 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2017-06-15 16:48:16 +0100 |
| commit | 724b4198b0cd8baf328166f3e60f804ad9a6151b (patch) | |
| tree | 9d4fc16c0a4b7d21c55bcbe37e890bb3aa9d2bcc /src | |
| parent | 8bee02c8bb5630b4bc619fb3b76de5e20abaf74d (diff) | |
Change window display to not use invalid buffer coordinates
Fixes #1435
Diffstat (limited to 'src')
| -rw-r--r-- | src/highlighters.cc | 10 | ||||
| -rw-r--r-- | src/window.cc | 8 |
2 files changed, 12 insertions, 6 deletions
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(); |
