From 97bdb15bd6251146b358f810b263b7454d0eaf03 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Wed, 28 Sep 2016 14:07:17 -0400 Subject: [PATCH] Revert "fixes #379" --- cmd/micro/util.go | 21 ++------------------- cmd/micro/view.go | 3 +-- 2 files changed, 3 insertions(+), 21 deletions(-) diff --git a/cmd/micro/util.go b/cmd/micro/util.go index 38d6ef72..4402a22e 100644 --- a/cmd/micro/util.go +++ b/cmd/micro/util.go @@ -157,18 +157,7 @@ func GetModTime(path string) (time.Time, bool) { // StringWidth returns the width of a string where tabs count as `tabsize` width func StringWidth(str string, tabsize int) int { sw := runewidth.StringWidth(str) - lineIdx := 0 - for _, ch := range str { - switch ch { - case '\t': - ts := tabsize - (lineIdx % tabsize) - sw += ts - 1 - case '\n': - lineIdx = 0 - default: - lineIdx++ - } - } + sw += NumOccurrences(str, '\t') * (tabsize - 1) return sw } @@ -176,22 +165,16 @@ func StringWidth(str string, tabsize int) int { // that have a width larger than 1 (this also counts tabs as `tabsize` width) func WidthOfLargeRunes(str string, tabsize int) int { count := 0 - lineIdx := 0 for _, ch := range str { var w int if ch == '\t' { - w = tabsize - (lineIdx % tabsize) + w = tabsize } else { w = runewidth.RuneWidth(ch) } if w > 1 { count += (w - 1) } - if ch == '\n' { - lineIdx = 0 - } else { - lineIdx++ - } } return count } diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 2ab29ad6..aef1ccea 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -777,8 +777,7 @@ func (v *View) DisplayView() { } // Now the tab has to be displayed as a bunch of spaces tabSize := int(v.Buf.Settings["tabsize"].(float64)) - remainder := tabSize - (colN % tabSize) - for i := 0; i < remainder-1; i++ { + for i := 0; i < tabSize-1; i++ { screenX++ if screenX-v.x-v.leftCol >= v.lineNumOffset { v.drawCell(screenX-v.leftCol, screenY, ' ', nil, lineStyle)