parent
093d3bd0df
commit
b934bcd4e1
|
@ -1590,6 +1590,12 @@ void ensure_forward(Context& context, NormalParams)
|
||||||
context.selections().check_invariant();
|
context.selections().check_invariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void merge_consecutive(Context& context, NormalParams params)
|
||||||
|
{
|
||||||
|
ensure_forward(context, params);
|
||||||
|
context.selections().merge_consecutive();
|
||||||
|
}
|
||||||
|
|
||||||
void force_redraw(Context& context, NormalParams)
|
void force_redraw(Context& context, NormalParams)
|
||||||
{
|
{
|
||||||
if (context.has_client())
|
if (context.has_client())
|
||||||
|
@ -1663,6 +1669,7 @@ static NormalCmdDesc cmds[] =
|
||||||
{ ';', "reduce selections to their cursor", clear_selections },
|
{ ';', "reduce selections to their cursor", clear_selections },
|
||||||
{ alt(';'), "swap selections cursor and anchor", flip_selections },
|
{ alt(';'), "swap selections cursor and anchor", flip_selections },
|
||||||
{ alt(':'), "ensure selection cursor is after anchor", ensure_forward },
|
{ alt(':'), "ensure selection cursor is after anchor", ensure_forward },
|
||||||
|
{ alt('m'), "merge consecutive selections", merge_consecutive },
|
||||||
|
|
||||||
{ 'w', "select to next word start", repeated<&select<SelectMode::Replace, select_to_next_word<Word>>> },
|
{ 'w', "select to next word start", repeated<&select<SelectMode::Replace, select_to_next_word<Word>>> },
|
||||||
{ 'e', "select to next word end", repeated<select<SelectMode::Replace, select_to_next_word_end<Word>>> },
|
{ 'e', "select to next word end", repeated<select<SelectMode::Replace, select_to_next_word_end<Word>>> },
|
||||||
|
|
|
@ -445,6 +445,18 @@ void SelectionList::merge_overlapping()
|
||||||
m_main, overlaps), end());
|
m_main, overlaps), end());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SelectionList::merge_consecutive()
|
||||||
|
{
|
||||||
|
if (size() == 1)
|
||||||
|
return;
|
||||||
|
|
||||||
|
auto touches = [this](const Selection& lhs, const Selection& rhs) {
|
||||||
|
return m_buffer->char_next(lhs.max()) >= rhs.min();
|
||||||
|
};
|
||||||
|
m_selections.erase(Kakoune::merge_overlapping(begin(), end(),
|
||||||
|
m_main, touches), end());
|
||||||
|
}
|
||||||
|
|
||||||
void SelectionList::sort_and_merge_overlapping()
|
void SelectionList::sort_and_merge_overlapping()
|
||||||
{
|
{
|
||||||
sort();
|
sort();
|
||||||
|
|
|
@ -126,6 +126,7 @@ struct SelectionList
|
||||||
|
|
||||||
void sort();
|
void sort();
|
||||||
void merge_overlapping();
|
void merge_overlapping();
|
||||||
|
void merge_consecutive();
|
||||||
void sort_and_merge_overlapping();
|
void sort_and_merge_overlapping();
|
||||||
|
|
||||||
Buffer& buffer() const { return *m_buffer; }
|
Buffer& buffer() const { return *m_buffer; }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user