diff --git a/cmd/micro/command.go b/cmd/micro/command.go index 1e41a7b2..f38edf38 100644 --- a/cmd/micro/command.go +++ b/cmd/micro/command.go @@ -149,7 +149,7 @@ func HandleCommand(input string, view *View) { if strings.Contains(flags, "c") { // The 'check' flag was used Search(search, view, true) - view.Relocate() + view.Relocate(0) Redraw(view) choice, canceled := messenger.YesNoPrompt("Perform replacement? (y,n)") if canceled { diff --git a/cmd/micro/search.go b/cmd/micro/search.go index 227e3af9..edabfbf9 100644 --- a/cmd/micro/search.go +++ b/cmd/micro/search.go @@ -121,7 +121,7 @@ func Search(searchStr string, v *View, down bool) { 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) - if v.Relocate() { + if v.Relocate(4) { v.matches = Match(v) } lastSearch = searchStr diff --git a/cmd/micro/view.go b/cmd/micro/view.go index 6b33f6d2..bb3d05c7 100644 --- a/cmd/micro/view.go +++ b/cmd/micro/view.go @@ -196,21 +196,21 @@ func (v *View) ReOpen() { v.Buf = buf v.matches = Match(v) v.Cursor.Relocate() - v.Relocate() + v.Relocate(0) } } // Relocate moves the view window so that the cursor is in view // This is useful if the user has scrolled far away, and then starts typing -func (v *View) Relocate() bool { +func (v *View) Relocate(x int) bool { ret := false cy := v.Cursor.y if cy < v.Topline { - v.Topline = cy - 4 + v.Topline = cy - x ret = true } if cy > v.Topline+v.height-1 { - v.Topline = cy - v.height + 5 + v.Topline = cy - v.height + 1 + x ret = true } @@ -378,7 +378,7 @@ func (v *View) HandleEvent(event tcell.Event) { } if relocate { - v.Relocate() + v.Relocate(0) } if settings["syntax"].(bool) { v.matches = Match(v)