mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-29 06:12:35 +09:00
Minor optimization to tabsize fix
This commit is contained in:
@@ -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
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user