Skip to content

Commit 1d40d03

Browse files
committed
refactor
1 parent 9a9e3d5 commit 1d40d03

File tree

1 file changed

+8
-14
lines changed

1 file changed

+8
-14
lines changed

pkg/gui/list_context.go

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ package gui
22

33
import (
44
"fmt"
5+
6+
"github.com/jesseduffield/gocui"
57
)
68

79
type ListContext struct {
@@ -160,22 +162,14 @@ func (self *ListContext) handleNextLine() error {
160162
}
161163

162164
func (self *ListContext) handleScrollLeft() error {
163-
if self.ignoreKeybinding() {
164-
return nil
165-
}
166-
167-
// get the view, move the origin
168-
view, err := self.Gui.g.View(self.ViewName)
169-
if err != nil {
170-
return nil
171-
}
172-
173-
self.Gui.scrollLeft(view)
174-
175-
return self.HandleFocus()
165+
return self.scroll(self.Gui.scrollLeft)
176166
}
177167

178168
func (self *ListContext) handleScrollRight() error {
169+
return self.scroll(self.Gui.scrollRight)
170+
}
171+
172+
func (self *ListContext) scroll(scrollFunc func(*gocui.View)) error {
179173
if self.ignoreKeybinding() {
180174
return nil
181175
}
@@ -186,7 +180,7 @@ func (self *ListContext) handleScrollRight() error {
186180
return nil
187181
}
188182

189-
self.Gui.scrollRight(view)
183+
scrollFunc(view)
190184

191185
return self.HandleFocus()
192186
}

0 commit comments

Comments
 (0)