summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMaxime Coste <mawww@kakoune.org>2018-11-14 17:47:11 +1100
committerMaxime Coste <mawww@kakoune.org>2018-11-14 17:47:11 +1100
commitb9ca3ee6dcca94b597e9ce4bfc505f0a7f4d6bfe (patch)
treea4abb7a409d18ae9ef1e625ed149505ad9cd30df /src
parentb96ab674790591715020d7e1f531ab303820244b (diff)
Fix column highlighter adding display atoms past the window width
Diffstat (limited to 'src')
-rw-r--r--src/highlighters.cc25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/highlighters.cc b/src/highlighters.cc
index dbc7e8eb..1f8dbfa9 100644
--- a/src/highlighters.cc
+++ b/src/highlighters.cc
@@ -595,36 +595,37 @@ std::unique_ptr<Highlighter> create_column_highlighter(HighlighterParameters par
if (column < 0)
return;
- auto face = context.context.faces()[facespec];
- auto win_column = context.setup.window_pos.column;
+ const auto face = context.context.faces()[facespec];
+ const auto win_column = context.setup.window_pos.column;
+ const auto target_col = column - win_column;
+ if (target_col < 0 or target_col >= context.setup.window_range.column)
+ return;
+
for (auto& line : display_buffer.lines())
{
- auto target_col = column - win_column;
- if (target_col < 0)
- return;
-
+ auto remaining_col = target_col;
bool found = false;
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)
{
const auto atom_len = atom_it->length();
- if (target_col < atom_len)
+ if (remaining_col < atom_len)
{
- if (target_col > 0)
- atom_it = ++line.split(atom_it, target_col);
+ if (remaining_col > 0)
+ atom_it = ++line.split(atom_it, remaining_col);
if (atom_it->length() > 1)
atom_it = line.split(atom_it, 1_col);
atom_it->face = merge_faces(atom_it->face, face);
found = true;
break;
}
- target_col -= atom_len;
+ remaining_col -= atom_len;
}
if (found)
continue;
- if (target_col > 0)
- line.push_back({String{' ', target_col}, {}});
+ if (remaining_col > 0)
+ line.push_back({String{' ', remaining_col}, {}});
line.push_back({" ", face});
}
};