Handle nav resizes (#2218)
* Handle nav resizes * Update `CHANGELOG.md`
This commit is contained in:
1 parent
7b6b6da100
commit
a7f7e84e81
5 files changed
+26
-18
No files matched your search
+2
-1
@@ -33,7 +33,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
||||
- A bug where the `source` command does not show an error message upon failure is now fixed (#2189).
|
||||
- The `addcustominfo` command as well as the `cleaner` and `previewer` options now support file completions (#2198) (#2211).
|
||||
- A bug where an empty `custom` info property would still take up space is now fixed (#2208).
|
||||
- A bug where setting `drawbox` could lead to scrolling outside the view is now fixed (#2210).
|
||||
- A bug where setting `drawbox` could lead to scrolling outside the view is now fixed (#2210) (#2218).
|
||||
- The preview cache is now not cleared when setting `ratios` to its current value (#2218).
|
||||
|
||||
## [r38](https://github.com/gokcehan/lf/releases/tag/r38)
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ func run() {
|
||||
screen.EnablePaste()
|
||||
|
||||
ui := newUI(screen)
|
||||
nav := newNav(ui.wins[0].h)
|
||||
nav := newNav(ui)
|
||||
app := newApp(ui, nav)
|
||||
|
||||
if err := nav.sync(); err != nil {
|
||||
|
||||
@@ -90,10 +90,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
err = applyBoolOpt(&gOpts.drawbox, e)
|
||||
if err == nil {
|
||||
app.ui.renew()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
clear(app.nav.regCache)
|
||||
}
|
||||
app.nav.resize(app.ui)
|
||||
app.ui.loadFile(app, true)
|
||||
}
|
||||
case "hidden", "nohidden", "hidden!":
|
||||
@@ -346,7 +343,7 @@ func (e *setExpr) eval(app *app, args []string) {
|
||||
}
|
||||
gOpts.ratios = rats
|
||||
app.ui.wins = getWins(app.ui.screen)
|
||||
clear(app.nav.regCache)
|
||||
app.nav.resize(app.ui)
|
||||
app.ui.loadFile(app, true)
|
||||
case "rulerfmt":
|
||||
gOpts.rulerfmt = e.val
|
||||
@@ -1285,15 +1282,9 @@ func (e *callExpr) eval(app *app, args []string) {
|
||||
if !app.nav.init {
|
||||
return
|
||||
}
|
||||
app.ui.renew()
|
||||
app.ui.screen.Sync()
|
||||
if app.nav.height != app.ui.wins[0].h {
|
||||
app.nav.height = app.ui.wins[0].h
|
||||
clear(app.nav.regCache)
|
||||
}
|
||||
for _, dir := range app.nav.dirs {
|
||||
dir.boundPos(app.nav.height)
|
||||
}
|
||||
app.ui.renew()
|
||||
app.nav.resize(app.ui)
|
||||
app.ui.sxScreen.forceClear = true
|
||||
app.ui.loadFile(app, true)
|
||||
onRedraw(app)
|
||||
|
||||
@@ -470,6 +470,7 @@ type nav struct {
|
||||
tags map[string]string
|
||||
selectionInd int
|
||||
height int
|
||||
previewWidth int
|
||||
find string
|
||||
findBack bool
|
||||
search string
|
||||
@@ -582,7 +583,7 @@ func (nav *nav) getDirs(wd string) {
|
||||
nav.dirs = dirs
|
||||
}
|
||||
|
||||
func newNav(height int) *nav {
|
||||
func newNav(ui *ui) *nav {
|
||||
nav := &nav{
|
||||
copyJobsChan: make(chan int, 1024),
|
||||
copyBytesChan: make(chan int64, 1024),
|
||||
@@ -602,12 +603,12 @@ func newNav(height int) *nav {
|
||||
selections: make(map[string]int),
|
||||
tags: make(map[string]string),
|
||||
selectionInd: 0,
|
||||
height: height,
|
||||
previewTimer: time.NewTimer(0),
|
||||
jumpList: make([]string, 0),
|
||||
jumpListInd: -1,
|
||||
}
|
||||
|
||||
nav.resize(ui)
|
||||
return nav
|
||||
}
|
||||
|
||||
@@ -670,6 +671,22 @@ func (nav *nav) reload() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (nav *nav) resize(ui *ui) {
|
||||
previewWin := ui.wins[len(ui.wins)-1]
|
||||
if previewWin.h == nav.height && previewWin.w == nav.previewWidth {
|
||||
return
|
||||
}
|
||||
|
||||
nav.height = previewWin.h
|
||||
nav.previewWidth = previewWin.w
|
||||
|
||||
for _, dir := range nav.dirs {
|
||||
dir.boundPos(nav.height)
|
||||
}
|
||||
|
||||
clear(nav.regCache)
|
||||
}
|
||||
|
||||
func (nav *nav) position() {
|
||||
if !nav.init {
|
||||
return
|
||||
|
||||
@@ -1720,7 +1720,6 @@ func (ui *ui) readNormalEvent(ev tcell.Event, nav *nav) expr {
|
||||
return &callExpr{"cd", []string{dir.path}, 1}
|
||||
}
|
||||
case *tcell.EventResize:
|
||||
clear(nav.regCache)
|
||||
return &callExpr{"redraw", nil, 1}
|
||||
case *tcell.EventError:
|
||||
log.Printf("Got EventError: '%s' at %s", tev.Error(), tev.When())
|
||||
|
||||
Reference in new issue
Block a user