mirror of
https://github.com/zyedidia/micro.git
synced 2026-03-16 05:47:06 +09:00
Add padding to relocate func (fixes weird scrolling behavior)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user