]> git.lizzy.rs Git - micro.git/blobdiff - cmd/micro/search.go
Fix crash
[micro.git] / cmd / micro / search.go
index 4253a316026dc3e0c7338a1411c6ece71b6ebc48..227e3af9e370141dd09722803680436208eb5e1a 100644 (file)
@@ -84,6 +84,9 @@ func Search(searchStr string, v *View, down bool) {
                str = text[:searchStart]
        }
        r, err := regexp.Compile(searchStr)
+       if settings["ignorecase"].(bool) {
+               r, err = regexp.Compile("(?i)" + searchStr)
+       }
        if err != nil {
                return
        }
@@ -111,6 +114,10 @@ func Search(searchStr string, v *View, down bool) {
                match = matches[0]
        }
 
+       if match[0] == match[1] {
+               return
+       }
+
        v.Cursor.curSelection[0] = charPos + match[0]
        v.Cursor.curSelection[1] = charPos + match[1]
        v.Cursor.x, v.Cursor.y = FromCharPos(charPos+match[1]-1, v.Buf)