diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-07-13 12:24:14 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-07-13 12:24:14 +1000 |
| commit | c7fbf1f3905f77f136e898479352e590787434d2 (patch) | |
| tree | 190edecbc65bac3c2e03a53b62056b3a981cd90a /src/display_buffer.cc | |
| parent | 195fe8fd29a1824372ff69e6ef8b8e5be8bc9a07 (diff) | |
Re-work line trimming to fix issues with column highighters
Instead of triming only buffer ranges, add a trim_from method to
display line to keep the initial N columns, we know how many columns
are used by non-trimable widgets in DisplaySetup::widget_columns so
we can just pass this.
Also restore the previous logic for face merging
Fixes #4670
Diffstat (limited to 'src/display_buffer.cc')
| -rw-r--r-- | src/display_buffer.cc | 34 |
1 files changed, 25 insertions, 9 deletions
diff --git a/src/display_buffer.cc b/src/display_buffer.cc index 2b377310..335fb5de 100644 --- a/src/display_buffer.cc +++ b/src/display_buffer.cc @@ -193,29 +193,45 @@ ColumnCount DisplayLine::length() const return len; } -bool DisplayLine::trim(ColumnCount first_col, ColumnCount col_count, bool only_buffer) +bool DisplayLine::trim(ColumnCount front, ColumnCount col_count) { - for (auto it = begin(); first_col > 0 and it != end(); ) + return trim_from(0_col, front, col_count); +} + +bool DisplayLine::trim_from(ColumnCount first_col, ColumnCount front, ColumnCount col_count) +{ + auto it = begin(); + while (first_col > 0 and it != end()) { - if (only_buffer and !it->has_buffer_range()) + auto len = it->length(); + if (len <= first_col) { ++it; - continue; + first_col -= len; } + else + { + it = ++split(it, front); + first_col = 0; + } + } + while (front > 0 and it != end()) + { auto len = it->length(); - if (len <= first_col) + if (len <= front) { m_atoms.erase(it); - first_col -= len; + front -= len; } else { - it->trim_begin(first_col); - first_col = 0; + it->trim_begin(front); + front = 0; } } - auto it = begin(); + + it = begin(); for (; it != end() and col_count > 0; ++it) col_count -= it->length(); |
