Add + key to duplicate selections and <a-+> to merge overlapping ones
This is an experiment and might get reverted if overlapping selections prove too cumbersome. Fixes #4041
This commit is contained in:
parent
dea44e4964
commit
fa3aa3c1a3
|
@ -286,6 +286,12 @@ Yanking (copying) and pasting use the *"* register by default (See <<registers#,
|
|||
*<a-_>*::
|
||||
merge contiguous selections together (works across lines as well)
|
||||
|
||||
*<+>*, *<plus>*::
|
||||
duplicate each selection (generating overlapping selections)
|
||||
|
||||
*<a-+>*, *<a-plus>*::
|
||||
merge overlapping selections
|
||||
|
||||
*>*, *<gt>*::
|
||||
indent selected lines
|
||||
|
||||
|
|
|
@ -1555,8 +1555,6 @@ private:
|
|||
kak_assert(false); // invalid for interactive insert
|
||||
break;
|
||||
}
|
||||
if (mode != InsertMode::Append and mode != InsertMode::Replace)
|
||||
selections.sort_and_merge_overlapping();
|
||||
selections.check_invariant();
|
||||
buffer.check_invariant();
|
||||
}
|
||||
|
|
|
@ -2146,6 +2146,22 @@ void merge_consecutive(Context& context, NormalParams params)
|
|||
context.selections().merge_consecutive();
|
||||
}
|
||||
|
||||
void merge_overlapping(Context& context, NormalParams params)
|
||||
{
|
||||
ensure_forward(context, params);
|
||||
context.selections().merge_overlapping();
|
||||
}
|
||||
|
||||
void duplicate_selections(Context& context, NormalParams params)
|
||||
{
|
||||
SelectionList& sels = context.selections();
|
||||
Vector<Selection> new_sels;
|
||||
const int count = params.count ? params.count : 2;
|
||||
for (const auto& sel : sels)
|
||||
new_sels.insert(new_sels.end(), count, sel);
|
||||
context.selections().set(std::move(new_sels), sels.main_index() * count);
|
||||
}
|
||||
|
||||
void force_redraw(Context& context, NormalParams)
|
||||
{
|
||||
if (context.has_client())
|
||||
|
@ -2258,6 +2274,8 @@ static constexpr HashMap<Key, NormalCmd, MemoryDomain::Undefined, KeymapBackend>
|
|||
{ {alt(';')}, {"swap selections cursor and anchor", flip_selections} },
|
||||
{ {alt(':')}, {"ensure selection cursor is after anchor", ensure_forward} },
|
||||
{ {alt('_')}, {"merge consecutive selections", merge_consecutive} },
|
||||
{ {'+'}, {"duplicate each selection", duplicate_selections} },
|
||||
{ {alt('+')}, {"merge overlapping selections", merge_overlapping} },
|
||||
|
||||
{ {'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>>>} },
|
||||
|
|
|
@ -48,7 +48,7 @@ void SelectionList::set(Vector<Selection> list, size_t main)
|
|||
m_selections = std::move(list);
|
||||
m_main = main;
|
||||
m_timestamp = m_buffer->timestamp();
|
||||
sort_and_merge_overlapping();
|
||||
sort();
|
||||
check_invariant();
|
||||
}
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
%<a-s>|[ $kak_selection = "bar" ] && echo "yes"<ret>
|
||||
%<a-s>|[ $kak_selection = "bar" ] && echo "yes"<ret><a-+>
|
||||
|
|
|
@ -1 +1 @@
|
|||
2o<esc>|echo>&2<ret>
|
||||
2o<esc>|echo>&2<ret><a-+>
|
||||
|
|
Loading…
Reference in New Issue
Block a user