mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 22:27:13 +09:00
@@ -588,14 +588,20 @@ func (v *View) IndentSelection(usePlugin bool) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v.Cursor.HasSelection() {
|
if v.Cursor.HasSelection() {
|
||||||
startY := v.Cursor.CurSelection[0].Y
|
start := v.Cursor.CurSelection[0]
|
||||||
endY := v.Cursor.CurSelection[1].Move(-1, v.Buf).Y
|
end := v.Cursor.CurSelection[1]
|
||||||
endX := v.Cursor.CurSelection[1].Move(-1, v.Buf).X
|
if end.Y < start.Y {
|
||||||
|
start, end = end, start
|
||||||
|
}
|
||||||
|
|
||||||
|
startY := start.Y
|
||||||
|
endY := end.Move(-1, v.Buf).Y
|
||||||
|
endX := end.Move(-1, v.Buf).X
|
||||||
for y := startY; y <= endY; y++ {
|
for y := startY; y <= endY; y++ {
|
||||||
tabsize := len(v.Buf.IndentString())
|
tabsize := len(v.Buf.IndentString())
|
||||||
v.Buf.Insert(Loc{0, y}, v.Buf.IndentString())
|
v.Buf.Insert(Loc{0, y}, v.Buf.IndentString())
|
||||||
if y == startY && v.Cursor.CurSelection[0].X > 0 {
|
if y == startY && start.X > 0 {
|
||||||
v.Cursor.SetSelectionStart(v.Cursor.CurSelection[0].Move(tabsize, v.Buf))
|
v.Cursor.SetSelectionStart(start.Move(tabsize, v.Buf))
|
||||||
}
|
}
|
||||||
if y == endY {
|
if y == endY {
|
||||||
v.Cursor.SetSelectionEnd(Loc{endX + tabsize + 1, endY})
|
v.Cursor.SetSelectionEnd(Loc{endX + tabsize + 1, endY})
|
||||||
@@ -643,17 +649,23 @@ func (v *View) OutdentSelection(usePlugin bool) bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if v.Cursor.HasSelection() {
|
if v.Cursor.HasSelection() {
|
||||||
startY := v.Cursor.CurSelection[0].Y
|
start := v.Cursor.CurSelection[0]
|
||||||
endY := v.Cursor.CurSelection[1].Move(-1, v.Buf).Y
|
end := v.Cursor.CurSelection[1]
|
||||||
endX := v.Cursor.CurSelection[1].Move(-1, v.Buf).X
|
if end.Y < start.Y {
|
||||||
|
start, end = end, start
|
||||||
|
}
|
||||||
|
|
||||||
|
startY := start.Y
|
||||||
|
endY := end.Move(-1, v.Buf).Y
|
||||||
|
endX := end.Move(-1, v.Buf).X
|
||||||
for y := startY; y <= endY; y++ {
|
for y := startY; y <= endY; y++ {
|
||||||
for x := 0; x < len(v.Buf.IndentString()); x++ {
|
for x := 0; x < len(v.Buf.IndentString()); x++ {
|
||||||
if len(GetLeadingWhitespace(v.Buf.Line(y))) == 0 {
|
if len(GetLeadingWhitespace(v.Buf.Line(y))) == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
v.Buf.Remove(Loc{0, y}, Loc{1, y})
|
v.Buf.Remove(Loc{0, y}, Loc{1, y})
|
||||||
if y == startY && v.Cursor.CurSelection[0].X > 0 {
|
if y == startY && start.X > 0 {
|
||||||
v.Cursor.SetSelectionStart(v.Cursor.CurSelection[0].Move(-1, v.Buf))
|
v.Cursor.SetSelectionStart(start.Move(-1, v.Buf))
|
||||||
}
|
}
|
||||||
if y == endY {
|
if y == endY {
|
||||||
v.Cursor.SetSelectionEnd(Loc{endX - x, endY})
|
v.Cursor.SetSelectionEnd(Loc{endX - x, endY})
|
||||||
|
|||||||
Reference in New Issue
Block a user