diff options
| author | Maxime Coste <mawww@kakoune.org> | 2018-07-04 19:42:32 +1000 |
|---|---|---|
| committer | Maxime Coste <mawww@kakoune.org> | 2018-07-05 08:00:14 +1000 |
| commit | 63d4c8c3114862a49a2a4a54b2f229f9260bf291 (patch) | |
| tree | 47c562d1632fffbfcd2a7cadb0a410aa01f24dce /src/input_handler.cc | |
| parent | 55a5ec3bbdf7c605265859b5fde8ea1d4c02f15d (diff) | |
Change `a` on end of line behaviour to be consistent
`a` will just jump on next line, `a` on last end of line opens a new
line beneath it.
Fixes #1164
Diffstat (limited to 'src/input_handler.cc')
| -rw-r--r-- | src/input_handler.cc | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/input_handler.cc b/src/input_handler.cc index 51453e08..cf9773c9 100644 --- a/src/input_handler.cc +++ b/src/input_handler.cc @@ -1117,7 +1117,7 @@ public: { for (auto& sel : selections) { - if (sel.cursor() > sel.anchor() and sel.cursor().column > 0) + if (sel.cursor() > sel.anchor() and sel.cursor() > BufferCoord{0, 0}) sel.cursor() = context().buffer().char_prev(sel.cursor()); } } @@ -1362,11 +1362,9 @@ private: case InsertMode::Append: for (auto& sel : selections) { - sel.set(sel.min(), sel.max()); - auto& cursor = sel.cursor(); - // special case for end of lines, append to current line instead - if (cursor.column != buffer[cursor.line].length() - 1) - cursor = buffer.char_next(cursor); + sel.set(sel.min(), buffer.char_next(sel.max())); + if (sel.cursor() == buffer.end_coord()) + buffer.insert(buffer.end_coord(), "\n"); } break; case InsertMode::AppendAtLineEnd: @@ -1434,7 +1432,7 @@ private: ScopedEdition m_edition; InsertCompleter m_completer; - bool m_restore_cursor; + const bool m_restore_cursor; bool m_autoshowcompl; Timer m_idle_timer; bool m_in_end = false; |
