Minor optimization to tabsize fix

This commit is contained in:
Zachary Yedidia
2016-09-28 18:08:06 -04:00
parent 5e5dd78b7c
commit 32cd94b88f

View File

@@ -715,6 +715,8 @@ func (v *View) DisplayView() {
// Now we actually draw the line // Now we actually draw the line
colN := 0 colN := 0
strWidth := 0
tabSize := int(v.Buf.Settings["tabsize"].(float64))
for _, ch := range line { for _, ch := range line {
lineStyle := defStyle lineStyle := defStyle
@@ -776,8 +778,7 @@ func (v *View) DisplayView() {
v.drawCell(screenX-v.leftCol, screenY, indentChar[0], nil, lineIndentStyle) v.drawCell(screenX-v.leftCol, screenY, indentChar[0], nil, lineIndentStyle)
} }
// Now the tab has to be displayed as a bunch of spaces // Now the tab has to be displayed as a bunch of spaces
tabSize := int(v.Buf.Settings["tabsize"].(float64)) visLoc := strWidth
visLoc := StringWidth(line[:colN], tabSize)
remainder := tabSize - (visLoc % tabSize) remainder := tabSize - (visLoc % tabSize)
for i := 0; i < remainder-1; i++ { for i := 0; i < remainder-1; i++ {
screenX++ screenX++
@@ -803,6 +804,7 @@ func (v *View) DisplayView() {
charNum = charNum.Move(1, v.Buf) charNum = charNum.Move(1, v.Buf)
screenX++ screenX++
colN++ colN++
strWidth += StringWidth(string(ch), tabSize)
} }
// Here we are at a newline // Here we are at a newline