Append on end of line now appends to current line

This commit is contained in:
Maxime Coste 2012-11-26 19:23:50 +01:00
parent e77ca7a4be
commit cee0a2d128
3 changed files with 12 additions and 2 deletions

View File

@ -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:
{

View File

@ -26,6 +26,7 @@ enum class InsertMode : unsigned
Append,
Replace,
InsertAtLineBegin,
InsertAtNextLineBegin,
AppendAtLineEnd,
OpenLineBelow,
OpenLineAbove

View File

@ -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)