summaryrefslogtreecommitdiff
path: root/src/input_handler.cc
diff options
context:
space:
mode:
authorMaxime Coste <frrrwww@gmail.com>2016-10-23 18:48:16 +0100
committerMaxime Coste <frrrwww@gmail.com>2016-10-23 19:48:16 +0100
commitd2aa292c179d6824b17903deb5e8ddcb47ee8646 (patch)
treecc20f141ed5f10c28e3f1b5d65d2e4747001846c /src/input_handler.cc
parent1c97be5716af210bf1e97b6c4049a987c6bd053b (diff)
Change handling of OpenLineAbove to fix first line edge cases
Fixes #877
Diffstat (limited to 'src/input_handler.cc')
-rw-r--r--src/input_handler.cc19
1 files changed, 7 insertions, 12 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc
index 8c0ca802..87942afb 100644
--- a/src/input_handler.cc
+++ b/src/input_handler.cc
@@ -1212,18 +1212,13 @@ private:
break;
case InsertMode::OpenLineAbove:
for (auto& sel : selections)
- {
- auto line = sel.min().line;
- sel = line > 0 ? BufferCoord{line - 1, buffer[line-1].length() - 1}
- : BufferCoord{0, 0};
- }
- insert('\n');
- // fix case where we inserted at begining
- for (auto& sel : selections)
- {
- if (sel.anchor() == buffer.char_next({0,0}))
- sel = Selection{{0,0}};
- }
+ sel = BufferCoord{sel.min().line};
+ // Do not use insert method here as we need to fixup selection
+ // before running the InsertChar hook.
+ selections.insert("\n"_str, InsertMode::InsertCursor);
+ for (auto& sel : selections) // fix case where we inserted at begining
+ sel = BufferCoord{sel.cursor().line - 1};
+ context().hooks().run_hook("InsertChar", "\n", context());
break;
case InsertMode::InsertAtLineBegin:
for (auto& sel : selections)