Add Context::set_selections(std::vector<Selection>)
This methods avoids updating the context selection needlessly as they are going to get replaced anyway.
This commit is contained in:
parent
1b30c0f4fb
commit
a5e028e1b1
|
@ -202,6 +202,11 @@ std::vector<String> Context::selections_content() const
|
|||
return contents;
|
||||
}
|
||||
|
||||
void Context::set_selections(std::vector<Selection> sels)
|
||||
{
|
||||
*m_selections = std::move(sels);
|
||||
}
|
||||
|
||||
void Context::begin_edition()
|
||||
{
|
||||
if (m_edition_level >= 0)
|
||||
|
|
|
@ -51,6 +51,7 @@ public:
|
|||
SelectionList& selections();
|
||||
const SelectionList& selections() const;
|
||||
std::vector<String> selections_content() const;
|
||||
void set_selections(std::vector<Selection> sels);
|
||||
|
||||
void change_buffer(Buffer& buffer);
|
||||
|
||||
|
|
|
@ -725,7 +725,7 @@ void keep(Context& context, int)
|
|||
}
|
||||
if (keep.empty())
|
||||
throw runtime_error("no selections remaining");
|
||||
context.selections() = std::move(keep);
|
||||
context.set_selections(std::move(keep));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -749,7 +749,7 @@ void keep_pipe(Context& context, int)
|
|||
}
|
||||
if (keep.empty())
|
||||
throw runtime_error("no selections remaining");
|
||||
context.selections() = std::move(keep);
|
||||
context.set_selections(std::move(keep));
|
||||
});
|
||||
}
|
||||
template<bool indent_empty = false>
|
||||
|
@ -1213,7 +1213,7 @@ void undo(Context& context, int)
|
|||
{
|
||||
auto ranges = compute_modified_ranges(buffer, timestamp);
|
||||
if (not ranges.empty())
|
||||
context.selections() = std::move(ranges);
|
||||
context.set_selections(std::move(ranges));
|
||||
}
|
||||
else if (not res)
|
||||
context.print_status({ "nothing left to undo", get_color("Information") });
|
||||
|
@ -1229,7 +1229,7 @@ void redo(Context& context, int)
|
|||
{
|
||||
auto ranges = compute_modified_ranges(buffer, timestamp);
|
||||
if (not ranges.empty())
|
||||
context.selections() = std::move(ranges);
|
||||
context.set_selections(std::move(ranges));
|
||||
}
|
||||
|
||||
else if (not res)
|
||||
|
|
Loading…
Reference in New Issue
Block a user