Fix DisplayLines not tracking their buffer range correctly
After extracting the whole buffer content, a line can end up with only non-range highlgihters pending which makes its range become 0.0,0.0, after running highlighting on the extracted range it gets re-inserted but taking the min of existing range and inserted range wrongly returns 0.0. Avoid this by detecting that the 0.0,0.0 range does not actually mean anything when we have no ranged atoms. Fixes #5001
This commit is contained in:
parent
7e75c9a1df
commit
a1e6799aa9
|
@ -138,11 +138,12 @@ public:
|
|||
iterator insert(iterator pos, It beg, It end)
|
||||
{
|
||||
auto has_buffer_range = std::mem_fn(&DisplayAtom::has_buffer_range);
|
||||
auto had_range = any_of(*this, has_buffer_range);
|
||||
if (auto first = std::find_if(beg, end, has_buffer_range); first != end)
|
||||
{
|
||||
auto& last = *std::find_if(std::reverse_iterator(end), std::reverse_iterator(first), has_buffer_range);
|
||||
m_range.begin = std::min(m_range.begin, (*first).begin());
|
||||
m_range.end = std::max(m_range.end, last.end());
|
||||
m_range.begin = had_range ? std::min(m_range.begin, (*first).begin()) : (*first).begin();
|
||||
m_range.end = had_range ? std::max(m_range.end, last.end()) : last.end();
|
||||
}
|
||||
return m_atoms.insert(pos, beg, end);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
#foo
|
||||
bar
|
|
@ -0,0 +1,5 @@
|
|||
add-highlighter window/test regions
|
||||
add-highlighter window/test/macro region %{#} %{(?=\\n)} group
|
||||
add-highlighter window/test/code default-region group
|
||||
add-highlighter window/ number-lines
|
||||
add-highlighter window/ line 2 ,red
|
|
@ -0,0 +1,2 @@
|
|||
ui_out -ignore 1
|
||||
ui_out '{ "jsonrpc": "2.0", "method": "draw", "params": [[[{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 1│" }, { "face": { "fg": "black", "bg": "white", "underline": "default", "attributes": [] }, "contents": "#" }, { "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": "foo\u000a" }], [{ "face": { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, "contents": " 2│" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": "bar\u000a" }, { "face": { "fg": "default", "bg": "red", "underline": "default", "attributes": [] }, "contents": " " }]], { "fg": "default", "bg": "default", "underline": "default", "attributes": [] }, { "fg": "blue", "bg": "default", "underline": "default", "attributes": [] }] }'
|
Loading…
Reference in New Issue
Block a user