More consistent <space> and <a-space> behaviour
<space> and <a-space> without count now remove all except/keep main selection. Without reducing main selection to cursor. Reduce to cursor is moved to ';' and flip selections to <a-;>
This commit is contained in:
parent
60bf540ee6
commit
9439d28028
|
@ -1295,10 +1295,11 @@ KeyMap keymap =
|
||||||
{ ':', command },
|
{ ':', command },
|
||||||
{ '|', pipe<InsertMode::Replace> },
|
{ '|', pipe<InsertMode::Replace> },
|
||||||
{ alt('|'), pipe<InsertMode::Append> },
|
{ alt('|'), pipe<InsertMode::Append> },
|
||||||
{ ' ', [](Context& context, int count) { if (count == 0) clear_selections(context.selections());
|
{ ' ', [](Context& context, int count) { keep_selection(context.selections(), count ? count-1 : context.selections().main_index()); } },
|
||||||
else keep_selection(context.selections(), count-1); } },
|
{ alt(' '), [](Context& context, int count) { remove_selection(context.selections(), count ? count-1 : context.selections().main_index()); } },
|
||||||
{ alt(' '), [](Context& context, int count) { if (count == 0) flip_selections(context.selections());
|
{ ';', [](Context& context, int count) { clear_selections(context.selections()); } },
|
||||||
else remove_selection(context.selections(), count-1); } },
|
{ alt(';'), [](Context& context, int count) { flip_selections(context.selections()); } },
|
||||||
|
|
||||||
{ 'w', repeated(make_select<SelectMode::Replace>(select_to_next_word<Word>)) },
|
{ 'w', repeated(make_select<SelectMode::Replace>(select_to_next_word<Word>)) },
|
||||||
{ 'e', repeated(make_select<SelectMode::Replace>(select_to_next_word_end<Word>)) },
|
{ 'e', repeated(make_select<SelectMode::Replace>(select_to_next_word_end<Word>)) },
|
||||||
{ 'b', repeated(make_select<SelectMode::Replace>(select_to_previous_word<Word>)) },
|
{ 'b', repeated(make_select<SelectMode::Replace>(select_to_previous_word<Word>)) },
|
||||||
|
|
|
@ -11,12 +11,8 @@ namespace Kakoune
|
||||||
|
|
||||||
inline void clear_selections(SelectionList& selections)
|
inline void clear_selections(SelectionList& selections)
|
||||||
{
|
{
|
||||||
auto& sel = selections.main();
|
for (auto& sel : selections)
|
||||||
auto& pos = sel.cursor();
|
sel.anchor() = sel.cursor();
|
||||||
sel.anchor() = pos;
|
|
||||||
selections.avoid_eol();
|
|
||||||
|
|
||||||
selections = SelectionList{ selections.buffer(), std::move(sel) };
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void flip_selections(SelectionList& selections)
|
inline void flip_selections(SelectionList& selections)
|
||||||
|
@ -29,10 +25,7 @@ inline void flip_selections(SelectionList& selections)
|
||||||
inline void keep_selection(SelectionList& selections, int index)
|
inline void keep_selection(SelectionList& selections, int index)
|
||||||
{
|
{
|
||||||
if (index < selections.size())
|
if (index < selections.size())
|
||||||
{
|
selections = SelectionList{ selections.buffer(), std::move(selections[index]) };
|
||||||
size_t real_index = (index + selections.main_index() + 1) % selections.size();
|
|
||||||
selections = SelectionList{ selections.buffer(), std::move(selections[real_index]) };
|
|
||||||
}
|
|
||||||
selections.check_invariant();
|
selections.check_invariant();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,12 +33,10 @@ inline void remove_selection(SelectionList& selections, int index)
|
||||||
{
|
{
|
||||||
if (selections.size() > 1 and index < selections.size())
|
if (selections.size() > 1 and index < selections.size())
|
||||||
{
|
{
|
||||||
size_t real_index = (index + selections.main_index() + 1) % selections.size();
|
selections.remove(index);
|
||||||
selections.remove(real_index);
|
|
||||||
size_t main_index = selections.main_index();
|
size_t main_index = selections.main_index();
|
||||||
if (real_index <= main_index)
|
if (index < main_index or main_index == selections.size())
|
||||||
selections.set_main_index((main_index > 0 ? main_index
|
selections.set_main_index(main_index - 1);
|
||||||
: selections.size()) - 1);
|
|
||||||
}
|
}
|
||||||
selections.check_invariant();
|
selections.check_invariant();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user