]> git.lizzy.rs Git - micro.git/commitdiff
Fix horizontal scrolling
authorZachary Yedidia <zyedidia@gmail.com>
Fri, 22 Apr 2016 22:50:01 +0000 (18:50 -0400)
committerZachary Yedidia <zyedidia@gmail.com>
Fri, 22 Apr 2016 22:50:01 +0000 (18:50 -0400)
Fixes #59

cmd/micro/view.go

index 42cd178e9f4594cd11c0337f470c7a8b1f1c5144..2684e05feece9f41823f695791fde0d9eb2efd7a 100644 (file)
@@ -670,23 +670,19 @@ func (v *View) DisplayView() {
                }
                // Write the line
                tabchars := 0
-               runes := []rune(line)
-               for colN := v.leftCol; colN < v.leftCol+v.width; colN++ {
-                       if colN >= len(runes) {
-                               break
-                       }
-                       ch := runes[colN]
+               for colN, ch := range line {
                        var lineStyle tcell.Style
+
                        if settings.Syntax {
                                // Syntax highlighting is enabled
                                highlightStyle = v.matches[lineN][colN]
                        }
 
                        if v.cursor.HasSelection() &&
-                               (charNum >= v.cursor.curSelection[0] && charNum < v.cursor.curSelection[1] ||
-                                       charNum < v.cursor.curSelection[0] && charNum >= v.cursor.curSelection[1]) {
+                               (charNum >= v.cursor.curSelection[0] && charNum <= v.cursor.curSelection[1] ||
+                                       charNum <= v.cursor.curSelection[0] && charNum >= v.cursor.curSelection[1]) {
 
-                               lineStyle = defStyle.Reverse(true)
+                               lineStyle = tcell.StyleDefault.Reverse(true)
 
                                if style, ok := colorscheme["selection"]; ok {
                                        lineStyle = style
@@ -730,7 +726,6 @@ func (v *View) DisplayView() {
 
                charNum++
        }
-       // v.lastMatches = matches
 }
 
 // Display renders the view, the cursor, and statusline