]> git.lizzy.rs Git - micro.git/commitdiff
Fix text transformation bug
authorZachary Yedidia <zyedidia@gmail.com>
Tue, 25 Feb 2020 01:11:11 +0000 (20:11 -0500)
committerZachary Yedidia <zyedidia@gmail.com>
Tue, 25 Feb 2020 01:11:11 +0000 (20:11 -0500)
This fixes the remaining text transformation tests.

Ref #1526

internal/buffer/buffer.go
internal/buffer/eventhandler.go

index a89edc99ecdb8e8fe40362d4cd8919de12310971..10762e941c365506616304374f67d5d4be92f2ae 100644 (file)
@@ -7,7 +7,6 @@ import (
        "errors"
        "io"
        "io/ioutil"
-       "log"
        "os"
        "path"
        "path/filepath"
@@ -129,7 +128,6 @@ func (b *SharedBuffer) insert(pos Loc, value []byte) {
        b.LineArray.insert(pos, value)
 
        inslines := bytes.Count(value, []byte{'\n'})
-       log.Println("insert", string(value), pos.Y, pos.Y+inslines)
        b.MarkModified(pos.Y, pos.Y+inslines)
 }
 func (b *SharedBuffer) remove(start, end Loc) []byte {
@@ -148,12 +146,10 @@ func (b *SharedBuffer) MarkModified(start, end int) {
                return
        }
 
-       log.Println("Modified", start, end, len(b.lines))
        start = util.Clamp(start, 0, len(b.lines))
        end = util.Clamp(end, 0, len(b.lines))
 
        l := -1
-       log.Println("Modified", start, end)
        for i := start; i <= end; i++ {
                l = util.Max(b.Highlighter.ReHighlightStates(b, i), l)
        }
@@ -570,7 +566,6 @@ func (b *Buffer) UpdateRules() {
        if syntaxFile == "" {
                // search for the syntax file in the user's custom syntax files
                for _, f := range config.ListRealRuntimeFiles(config.RTSyntax) {
-                       log.Println("real runtime file", f.Name())
                        data, err := f.Data()
                        if err != nil {
                                screen.TermMessage("Error loading syntax file " + f.Name() + ": " + err.Error())
@@ -788,7 +783,6 @@ func (b *Buffer) ClearCursors() {
        b.UpdateCursors()
        b.curCursor = 0
        b.GetActiveCursor().ResetSelection()
-       log.Println("Cleared cursors:", len(b.cursors))
 }
 
 // MoveLinesUp moves the range of lines up one row
index 3dbc74e29d4a893e1ff88057bdb810ee5f1d94b0..4e4243a07953488adcf8310ec1104964e1752c3f 100644 (file)
@@ -180,7 +180,7 @@ func (eh *EventHandler) Remove(start, end Loc) {
 
        for _, c := range eh.cursors {
                move := func(loc Loc) Loc {
-                       if start.Y != end.Y && loc.GreaterThan(end) {
+                       if loc.Y != end.Y && loc.GreaterThan(end) {
                                loc.Y -= end.Y - start.Y
                        } else if loc.Y == end.Y && loc.GreaterEqual(end) {
                                loc = loc.MoveLA(-DiffLA(start, end, eh.buf.LineArray), eh.buf.LineArray)