]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/view.go
Merge pull request #499 from 10sr/addrmtrailingws
[micro.git] / cmd / micro / view.go
index 61b9b1409d192120df7d0bc117408867c639b7d2..1a2fad54240d64a26f0f94e475c52cb082091471 100644 (file)
@@ -120,7 +120,7 @@ func NewViewWidthHeight(buf *Buffer, w, h int) *View {
                v.Height--
        }
 
-       for _, pl := range loadedPlugins {
+       for pl := range loadedPlugins {
                _, err := Call(pl+".onViewOpen", v)
                if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
                        TermMessage(err)
@@ -418,9 +418,6 @@ func (v *View) MoveToMouseClick(x, y int) {
                v.ScrollDown(1)
                y = v.Height + v.Topline - 1
        }
-       if y >= v.Buf.NumLines {
-               y = v.Buf.NumLines - 1
-       }
        if y < 0 {
                y = 0
        }
@@ -487,7 +484,7 @@ func (v *View) HandleEvent(event tcell.Event) {
                        v.Buf.Insert(v.Cursor.Loc, string(e.Rune()))
                        v.Cursor.Right()
 
-                       for _, pl := range loadedPlugins {
+                       for pl := range loadedPlugins {
                                _, err := Call(pl+".onRune", string(e.Rune()), v)
                                if err != nil && !strings.HasPrefix(err.Error(), "function does not exist") {
                                        TermMessage(err)
@@ -889,6 +886,7 @@ func (v *View) DisplayView() {
                                                v.drawCell(screenX-v.leftCol, screenY, ' ', nil, lineStyle)
                                        }
                                }
+                               strWidth += remainder
                        } else if runewidth.RuneWidth(ch) > 1 {
                                if screenX-v.x-v.leftCol >= v.lineNumOffset {
                                        v.drawCell(screenX, screenY, ch, nil, lineStyle)
@@ -899,15 +897,16 @@ func (v *View) DisplayView() {
                                                v.drawCell(screenX-v.leftCol, screenY, '<', nil, lineStyle)
                                        }
                                }
+                               strWidth += StringWidth(string(ch), tabSize)
                        } else {
                                if screenX-v.x-v.leftCol >= v.lineNumOffset {
                                        v.drawCell(screenX-v.leftCol, screenY, ch, nil, lineStyle)
                                }
+                               strWidth += StringWidth(string(ch), tabSize)
                        }
                        charNum = charNum.Move(1, v.Buf)
                        screenX++
                        colN++
-                       strWidth += StringWidth(string(ch), tabSize)
                }
                // Here we are at a newline