]> git.lizzy.rs Git - micro.git/commitdiff
Fix weird behavior of JumpToMatchingBrace in some ill cases (#1966)
authorworldmaker <worldmaker18349276@gmail.com>
Sun, 24 Jul 2022 21:06:59 +0000 (05:06 +0800)
committerGitHub <noreply@github.com>
Sun, 24 Jul 2022 21:06:59 +0000 (14:06 -0700)
It should not return false immediately when no matching brace is found. This makes the jump fails in certain case: `[  )I]` =/=> `[I  )]`.
When there is no brace near the cursor, the last statement is also executed. This may cause problems when chaining commands.

internal/action/actions.go

index 9c76d6018e6b2b3988b270d0ca08fbf2414c0341..7900a917f6d23364dc0fec3dd93f14e3a60c2c4a 100644 (file)
@@ -9,6 +9,7 @@ import (
        "strings"
        "time"
 
+
        shellquote "github.com/kballard/go-shellquote"
        "github.com/zyedidia/micro/v2/internal/buffer"
        "github.com/zyedidia/micro/v2/internal/clipboard"
@@ -1267,15 +1268,12 @@ func (h *BufPane) JumpToMatchingBrace() bool {
                                } else {
                                        h.Cursor.GotoLoc(matchingBrace.Move(1, h.Buf))
                                }
-                               break
-                       } else {
-                               return false
+                               h.Relocate()
+                               return true
                        }
                }
        }
-
-       h.Relocate()
-       return true
+       return false
 }
 
 // SelectAll selects the entire buffer