Fix column highlighter adding display atoms past the window width
This commit is contained in:
parent
b96ab67479
commit
b9ca3ee6dc
|
@ -595,36 +595,37 @@ std::unique_ptr<Highlighter> create_column_highlighter(HighlighterParameters par
|
||||||
if (column < 0)
|
if (column < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto face = context.context.faces()[facespec];
|
const auto face = context.context.faces()[facespec];
|
||||||
auto win_column = context.setup.window_pos.column;
|
const auto win_column = context.setup.window_pos.column;
|
||||||
for (auto& line : display_buffer.lines())
|
const auto target_col = column - win_column;
|
||||||
{
|
if (target_col < 0 or target_col >= context.setup.window_range.column)
|
||||||
auto target_col = column - win_column;
|
|
||||||
if (target_col < 0)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
for (auto& line : display_buffer.lines())
|
||||||
|
{
|
||||||
|
auto remaining_col = target_col;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
auto first_buf = find_if(line, [](auto& atom) { return atom.has_buffer_range(); });
|
auto first_buf = find_if(line, [](auto& atom) { return atom.has_buffer_range(); });
|
||||||
for (auto atom_it = first_buf; atom_it != line.end(); ++atom_it)
|
for (auto atom_it = first_buf; atom_it != line.end(); ++atom_it)
|
||||||
{
|
{
|
||||||
const auto atom_len = atom_it->length();
|
const auto atom_len = atom_it->length();
|
||||||
if (target_col < atom_len)
|
if (remaining_col < atom_len)
|
||||||
{
|
{
|
||||||
if (target_col > 0)
|
if (remaining_col > 0)
|
||||||
atom_it = ++line.split(atom_it, target_col);
|
atom_it = ++line.split(atom_it, remaining_col);
|
||||||
if (atom_it->length() > 1)
|
if (atom_it->length() > 1)
|
||||||
atom_it = line.split(atom_it, 1_col);
|
atom_it = line.split(atom_it, 1_col);
|
||||||
atom_it->face = merge_faces(atom_it->face, face);
|
atom_it->face = merge_faces(atom_it->face, face);
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
target_col -= atom_len;
|
remaining_col -= atom_len;
|
||||||
}
|
}
|
||||||
if (found)
|
if (found)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (target_col > 0)
|
if (remaining_col > 0)
|
||||||
line.push_back({String{' ', target_col}, {}});
|
line.push_back({String{' ', remaining_col}, {}});
|
||||||
line.push_back({" ", face});
|
line.push_back({" ", face});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
1
test/regression/2562-column-highlighter-bleeding/in
Normal file
1
test/regression/2562-column-highlighter-bleeding/in
Normal file
|
@ -0,0 +1 @@
|
||||||
|
|
1
test/regression/2562-column-highlighter-bleeding/rc
Normal file
1
test/regression/2562-column-highlighter-bleeding/rc
Normal file
|
@ -0,0 +1 @@
|
||||||
|
add-highlighter window/ column 81 default,red
|
7
test/regression/2562-column-highlighter-bleeding/ui-out
Normal file
7
test/regression/2562-column-highlighter-bleeding/ui-out
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
{ "jsonrpc": "2.0", "method": "set_ui_options", "params": [{}] }
|
||||||
|
{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "black", "bg": "cyan", "attributes": [] }, "contents": "\u000a" }]], { "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": " - client0@[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] }
|
Loading…
Reference in New Issue
Block a user