From a50cb5f6e7969183c69b56578ad63cb61fe06227 Mon Sep 17 00:00:00 2001 From: Johannes Altmanninger Date: Sat, 3 Dec 2022 16:50:29 +0100 Subject: Share logic for undo/redo selection changes I will suggest a few changes to this code. No functional change. --- src/normal.cc | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) (limited to 'src/normal.cc') diff --git a/src/normal.cc b/src/normal.cc index 1142d871..7dc14382 100644 --- a/src/normal.cc +++ b/src/normal.cc @@ -1417,8 +1417,6 @@ void select_object(Context& context, NormalParams params) {{alt(';')}, "run command in object context"}})); } -enum Direction { Backward = -1, Forward = 1 }; - template void scroll(Context& context, NormalParams params) { @@ -2039,18 +2037,12 @@ void move_in_history(Context& context, NormalParams params) history_id, max_history_id)); } +template void undo_selection_change(Context& context, NormalParams params) { int count = std::max(1, params.count); while (count--) - context.undo_selection_change(); -} - -void redo_selection_change(Context& context, NormalParams params) -{ - int count = std::max(1, params.count); - while (count--) - context.redo_selection_change(); + context.undo_selection_change(); } void exec_user_mappings(Context& context, NormalParams params) @@ -2378,8 +2370,8 @@ static constexpr HashMap { {alt('u')}, {"move backward in history", move_in_history} }, { {alt('U')}, {"move forward in history", move_in_history} }, - { {ctrl('h')}, {"undo selection change", undo_selection_change} }, - { {ctrl('k')}, {"redo selection change", redo_selection_change} }, + { {ctrl('h')}, {"undo selection change", undo_selection_change} }, + { {ctrl('k')}, {"redo selection change", undo_selection_change} }, { {alt('i')}, {"select inner object", select_object} }, { {alt('a')}, {"select whole object", select_object} }, -- cgit v1.2.3