Merge pull request #764 from yannicka/master

OutdentSelection works on all cases (whatever tabsize or tabstospace values)
This commit is contained in:
Zachary Yedidia 2017-08-01 21:15:16 -04:00 committed by GitHub
commit 27f99b6309

View File

@ -786,19 +786,12 @@ func (v *View) OutdentSelection(usePlugin bool) bool {
startY := start.Y startY := start.Y
endY := end.Move(-1, v.Buf).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 && start.X > 0 {
v.Cursor.SetSelectionStart(start.Move(-1, v.Buf))
}
if y == endY {
v.Cursor.SetSelectionEnd(Loc{endX - x, endY})
}
} }
} }
v.Cursor.Relocate() v.Cursor.Relocate()