Change window display to not use invalid buffer coordinates

Fixes #1435
This commit is contained in:
Maxime Coste 2017-06-15 16:46:24 +01:00
parent 8bee02c8bb
commit 724b4198b0
6 changed files with 27 additions and 6 deletions

View File

@ -650,8 +650,14 @@ HighlighterAndId create_column_highlighter(HighlighterParameters params)
ColumnCount last_buffer_col = context.window().position().column; ColumnCount last_buffer_col = context.window().position().column;
for (auto& atom : line) for (auto& atom : line)
{ {
if (atom.has_buffer_range() and atom.begin() != atom.end()) if (atom.has_buffer_range())
last_buffer_col = get_column(buffer, tabstop, atom.end()); {
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; ColumnCount count = column - last_buffer_col;

View File

@ -132,11 +132,11 @@ const DisplayBuffer& Window::update_display_buffer(const Context& context)
if (buffer_line >= buffer().line_count()) if (buffer_line >= buffer().line_count())
break; break;
auto beg_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column}); auto beg_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column});
auto end_byte = setup.full_lines ? auto end_byte = get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column});
buffer()[buffer_line].length() : auto end_coord = setup.full_lines or end_byte == buffer()[buffer_line].length() ?
get_byte_to_column(buffer(), tabstop, {buffer_line, m_position.column + m_range.column}); 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(); m_display_buffer.compute_range();

View File

@ -0,0 +1 @@
O<space><a-;><c-l><esc>

View File

@ -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] }

View File

@ -0,0 +1 @@
add-highlighter show_whitespaces