From: Jon Craton Date: Sat, 15 Oct 2016 02:22:48 +0000 (-0400) Subject: DuplicateLine now duplicates the current selection if there is text selected X-Git-Tag: v1.1.2~12^2 X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;ds=sidebyside;h=78b0aac5ec26e1e671872578d55736c74d07ab48;p=micro.git DuplicateLine now duplicates the current selection if there is text selected --- diff --git a/cmd/micro/actions.go b/cmd/micro/actions.go index a316293b..0def2e39 100644 --- a/cmd/micro/actions.go +++ b/cmd/micro/actions.go @@ -922,15 +922,20 @@ func (v *View) Cut(usePlugin bool) bool { return false } -// DuplicateLine duplicates the current line +// DuplicateLine duplicates the current line or selection func (v *View) DuplicateLine(usePlugin bool) bool { if usePlugin && !PreActionCall("DuplicateLine", v) { return false } - v.Cursor.End() - v.Buf.Insert(v.Cursor.Loc, "\n"+v.Buf.Line(v.Cursor.Y)) - v.Cursor.Right() + if v.Cursor.HasSelection() { + v.Buf.Insert(v.Cursor.CurSelection[1], v.Cursor.GetSelection()) + } else { + v.Cursor.End() + v.Buf.Insert(v.Cursor.Loc, "\n"+v.Buf.Line(v.Cursor.Y)) + v.Cursor.Right() + } + messenger.Message("Duplicated line") if usePlugin {