mirror of
https://github.com/Hopiu/micro.git
synced 2026-03-28 20:00:24 +00:00
Merge pull request #416 from jncraton/duplicate-selection
DuplicateLine duplicates current selection if there is text selected
This commit is contained in:
commit
766f836952
1 changed files with 9 additions and 4 deletions
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in a new issue