diff options
| author | Maxime Coste <frrrwww@gmail.com> | 2012-11-26 19:23:50 +0100 |
|---|---|---|
| committer | Maxime Coste <frrrwww@gmail.com> | 2012-11-26 19:23:50 +0100 |
| commit | cee0a2d128bb843cd4a65dcddb66188ea825553e (patch) | |
| tree | cd89b5f1c528d90fcff585c665d447c9a6e3685c /src | |
| parent | e77ca7a4be3adc8d11503b1186b8fac257a1624c (diff) | |
Append on end of line now appends to current line
Diffstat (limited to 'src')
| -rw-r--r-- | src/editor.cc | 11 | ||||
| -rw-r--r-- | src/editor.hh | 1 | ||||
| -rw-r--r-- | src/main.cc | 2 |
3 files changed, 12 insertions, 2 deletions
diff --git a/src/editor.cc b/src/editor.cc index eeffe41f..7ad9b610 100644 --- a/src/editor.cc +++ b/src/editor.cc @@ -38,10 +38,19 @@ static BufferIterator prepare_insert(Buffer& buffer, const Selection& sel, case InsertMode::Replace: return sel.begin(); case InsertMode::Append: - return sel.end(); + { + // special case for end of lines, append to current line instead + auto pos = std::max(sel.first(), sel.last()); + if (pos.column() == buffer.line_length(pos.line()) - 1) + return pos; + else + return pos+1; + } case InsertMode::InsertAtLineBegin: return buffer.iterator_at_line_begin(sel.begin()); case InsertMode::AppendAtLineEnd: + return buffer.iterator_at_line_end(sel.end()-1)-1; + case InsertMode::InsertAtNextLineBegin: return buffer.iterator_at_line_end(sel.end()-1); case InsertMode::OpenLineBelow: { diff --git a/src/editor.hh b/src/editor.hh index 10239564..06b9378a 100644 --- a/src/editor.hh +++ b/src/editor.hh @@ -26,6 +26,7 @@ enum class InsertMode : unsigned Append, Replace, InsertAtLineBegin, + InsertAtNextLineBegin, AppendAtLineEnd, OpenLineBelow, OpenLineAbove diff --git a/src/main.cc b/src/main.cc index 9f252c5b..d05245b0 100644 --- a/src/main.cc +++ b/src/main.cc @@ -169,7 +169,7 @@ void do_change(Context& context) static InsertMode adapt_for_linewise(InsertMode mode) { if (mode == InsertMode::Append) - return InsertMode::AppendAtLineEnd; + return InsertMode::InsertAtNextLineBegin; if (mode == InsertMode::Insert) return InsertMode::InsertAtLineBegin; if (mode == InsertMode::Replace) |
