diff options
| author | Maxime Coste <mawww@kakoune.org> | 2022-07-12 19:41:50 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2022-07-12 21:11:53 +1000 |
| commit | 195fe8fd29a1824372ff69e6ef8b8e5be8bc9a07 (patch) | |
| tree | f56db6e31bbdab7597626eeae783988bda93ca83 /src | |
| parent | af89d6e05277d3ff816572856e41ed976a259707 (diff) | |
Fix past-the-eol column highlighter getting highlighted as buffer range
Make the column highlighter faces final, and change final logic to
give precedence to the base face when both the base and new face are
final.
Fixes #4669
Diffstat (limited to 'src')
| -rw-r--r-- | src/display_buffer.hh | 8 | ||||
| -rw-r--r-- | src/face.hh | 4 | ||||
| -rw-r--r-- | src/highlighters.cc | 17 |
3 files changed, 20 insertions, 9 deletions
diff --git a/src/display_buffer.hh b/src/display_buffer.hh index 6d739095..af37b18f 100644 --- a/src/display_buffer.hh +++ b/src/display_buffer.hh @@ -24,11 +24,11 @@ struct DisplayAtom : public UseMemoryDomain<MemoryDomain::Display> public: enum Type { Range, ReplacedRange, Text }; - DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end) - : m_type(Range), m_buffer(&buffer), m_range{begin, end} {} + DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end, Face face = {}) + : face(face), m_type(Range), m_buffer(&buffer), m_range{begin, end} {} - DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end, String str) - : m_type(ReplacedRange), m_buffer(&buffer), m_range{begin, end}, m_text{std::move(str)} {} + DisplayAtom(const Buffer& buffer, BufferCoord begin, BufferCoord end, String str, Face face = {}) + : face(face), m_type(ReplacedRange), m_buffer(&buffer), m_range{begin, end}, m_text{std::move(str)} {} DisplayAtom(String str, Face face) : face(face), m_type(Text), m_text(std::move(str)) {} diff --git a/src/face.hh b/src/face.hh index ce544116..e1047bcd 100644 --- a/src/face.hh +++ b/src/face.hh @@ -65,10 +65,10 @@ inline Face merge_faces(const Face& base, const Face& face) }; auto choose = [&](Color Face::*color, Attribute final_attr) { - if (face.attributes & final_attr) - return face.*color; if (base.attributes & final_attr) return base.*color; + if (face.attributes & final_attr) + return face.*color; if (face.*color == Color::Default) return base.*color; if ((base.*color).isRGB() and (face.*color).isRGB() and (face.*color).a != 255) diff --git a/src/highlighters.cc b/src/highlighters.cc index 6d370aae..5245b3c6 100644 --- a/src/highlighters.cc +++ b/src/highlighters.cc @@ -558,6 +558,17 @@ std::unique_ptr<Highlighter> create_dynamic_regex_highlighter(HighlighterParamet return make_hl(get_regex, get_face); } +namespace +{ + +Face make_final(Face face) +{ + face.attributes |= Attribute::Final; + return face; +} + +} + const HighlighterDesc line_desc = { "Parameters: <value string> <face>\n" "Highlight the line given by evaluating <value string> with <face>", @@ -604,7 +615,7 @@ std::unique_ptr<Highlighter> create_line_highlighter(HighlighterParameters param } const ColumnCount remaining = context.context.window().dimensions().column - column; if (remaining > 0) - it->push_back({ String{' ', remaining}, face }); + it->push_back({ String{' ', remaining}, make_final(face) }); }; return make_highlighter(std::move(func)); @@ -670,8 +681,8 @@ std::unique_ptr<Highlighter> create_column_highlighter(HighlighterParameters par continue; if (remaining_col > 0) - line.push_back({buffer, last_pos, last_pos, String{' ', remaining_col}}); - line.push_back({buffer, last_pos, last_pos, " "}).face = face; + line.push_back({buffer, last_pos, last_pos, String{' ', remaining_col}, make_final(Face{})}); + line.push_back({buffer, last_pos, last_pos, " ", make_final(face)}); } }; |
