Remove dircache option (#2110)
This commit is contained in:
1 parent
13da770af6
commit
06955cbacc
7 files changed
+33
-68
No files matched your search
@@ -391,22 +391,17 @@ func (app *app) loop() {
|
|||||||
}
|
}
|
||||||
app.ui.draw(app.nav)
|
app.ui.draw(app.nav)
|
||||||
case d := <-app.nav.dirChan:
|
case d := <-app.nav.dirChan:
|
||||||
if gOpts.dircache {
|
prev, ok := app.nav.dirCache[d.path]
|
||||||
prev, ok := app.nav.dirCache[d.path]
|
if ok {
|
||||||
if ok {
|
d.ind = prev.ind
|
||||||
d.ind = prev.ind
|
d.pos = prev.pos
|
||||||
d.pos = prev.pos
|
d.visualAnchor = min(prev.visualAnchor, len(d.files)-1)
|
||||||
d.visualAnchor = min(prev.visualAnchor, len(d.files)-1)
|
d.visualWrap = prev.visualWrap
|
||||||
d.visualWrap = prev.visualWrap
|
d.filter = prev.filter
|
||||||
d.filter = prev.filter
|
|
||||||
d.sort()
|
|
||||||
d.sel(prev.name(), app.nav.height)
|
|
||||||
}
|
|
||||||
|
|
||||||
app.nav.dirCache[d.path] = d
|
|
||||||
} else {
|
|
||||||
d.sort()
|
d.sort()
|
||||||
|
d.sel(prev.name(), app.nav.height)
|
||||||
}
|
}
|
||||||
|
app.nav.dirCache[d.path] = d
|
||||||
|
|
||||||
var oldCurrPath string
|
var oldCurrPath string
|
||||||
if curr, err := app.nav.currFile(); err == nil {
|
if curr, err := app.nav.currFile(); err == nil {
|
||||||
|
|||||||
@@ -155,7 +155,6 @@ The following options can be used to customize the behavior of lf:
|
|||||||
cursorparentfmt string (default "\033[7m")
|
cursorparentfmt string (default "\033[7m")
|
||||||
cursorpreviewfmt string (default "\033[4m")
|
cursorpreviewfmt string (default "\033[4m")
|
||||||
cutfmt string (default "\033[7;31m")
|
cutfmt string (default "\033[7;31m")
|
||||||
dircache bool (default true)
|
|
||||||
dircounts bool (default false)
|
dircounts bool (default false)
|
||||||
dirfirst bool (default true)
|
dirfirst bool (default true)
|
||||||
dironly bool (default false)
|
dironly bool (default false)
|
||||||
@@ -754,10 +753,6 @@ For example, `\033[4m%s\033[0m` has the same effect as `\033[4m`.
|
|||||||
|
|
||||||
Format string of the indicator for files to be cut.
|
Format string of the indicator for files to be cut.
|
||||||
|
|
||||||
## dircache (bool) (default true)
|
|
||||||
|
|
||||||
Cache directory contents.
|
|
||||||
|
|
||||||
## dircounts (bool) (default false)
|
## dircounts (bool) (default false)
|
||||||
|
|
||||||
When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using `calcdirsize`.
|
When this option is enabled, directory sizes show the number of items inside instead of the total size of the directory, which needs to be calculated for each directory using `calcdirsize`.
|
||||||
|
|||||||
@@ -145,7 +145,6 @@ The following options can be used to customize the behavior of lf:
|
|||||||
cursorparentfmt string (default "\033[7m")
|
cursorparentfmt string (default "\033[7m")
|
||||||
cursorpreviewfmt string (default "\033[4m")
|
cursorpreviewfmt string (default "\033[4m")
|
||||||
cutfmt string (default "\033[7;31m")
|
cutfmt string (default "\033[7;31m")
|
||||||
dircache bool (default true)
|
|
||||||
dircounts bool (default false)
|
dircounts bool (default false)
|
||||||
dirfirst bool (default true)
|
dirfirst bool (default true)
|
||||||
dironly bool (default false)
|
dironly bool (default false)
|
||||||
@@ -793,10 +792,6 @@ cutfmt (string) (default \033[7;31m)
|
|||||||
|
|
||||||
Format string of the indicator for files to be cut.
|
Format string of the indicator for files to be cut.
|
||||||
|
|
||||||
dircache (bool) (default true)
|
|
||||||
|
|
||||||
Cache directory contents.
|
|
||||||
|
|
||||||
dircounts (bool) (default false)
|
dircounts (bool) (default false)
|
||||||
|
|
||||||
When this option is enabled, directory sizes show the number of items
|
When this option is enabled, directory sizes show the number of items
|
||||||
|
|||||||
@@ -64,8 +64,6 @@ func (e *setExpr) eval(app *app, args []string) {
|
|||||||
err = applyBoolOpt(&gOpts.anchorfind, e)
|
err = applyBoolOpt(&gOpts.anchorfind, e)
|
||||||
case "autoquit", "noautoquit", "autoquit!":
|
case "autoquit", "noautoquit", "autoquit!":
|
||||||
err = applyBoolOpt(&gOpts.autoquit, e)
|
err = applyBoolOpt(&gOpts.autoquit, e)
|
||||||
case "dircache", "nodircache", "dircache!":
|
|
||||||
err = applyBoolOpt(&gOpts.dircache, e)
|
|
||||||
case "dircounts", "nodircounts", "dircounts!":
|
case "dircounts", "nodircounts", "dircounts!":
|
||||||
err = applyBoolOpt(&gOpts.dircounts, e)
|
err = applyBoolOpt(&gOpts.dircounts, e)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -621,11 +619,6 @@ func onChdir(app *app) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func onLoad(app *app, files []string) {
|
func onLoad(app *app, files []string) {
|
||||||
// prevent infinite loops
|
|
||||||
if !gOpts.dircache {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if cmd, ok := gOpts.cmds["on-load"]; ok {
|
if cmd, ok := gOpts.cmds["on-load"]; ok {
|
||||||
cmd.eval(app, files)
|
cmd.eval(app, files)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -160,7 +160,6 @@ cursoractivefmt string (default \(dq\(rs033[7m\(dq)
|
|||||||
cursorparentfmt string (default \(dq\(rs033[7m\(dq)
|
cursorparentfmt string (default \(dq\(rs033[7m\(dq)
|
||||||
cursorpreviewfmt string (default \(dq\(rs033[4m\(dq)
|
cursorpreviewfmt string (default \(dq\(rs033[4m\(dq)
|
||||||
cutfmt string (default \(dq\(rs033[7;31m\(dq)
|
cutfmt string (default \(dq\(rs033[7;31m\(dq)
|
||||||
dircache bool (default true)
|
|
||||||
dircounts bool (default false)
|
dircounts bool (default false)
|
||||||
dirfirst bool (default true)
|
dirfirst bool (default true)
|
||||||
dironly bool (default false)
|
dironly bool (default false)
|
||||||
@@ -698,8 +697,6 @@ For example, \f[CR]\(rs033[4m%s\(rs033[0m\f[R] has the same effect as
|
|||||||
\f[CR]\(rs033[4m\f[R].
|
\f[CR]\(rs033[4m\f[R].
|
||||||
.SS cutfmt (string) (default \f[CR]\(rs033[7;31m\f[R])
|
.SS cutfmt (string) (default \f[CR]\(rs033[7;31m\f[R])
|
||||||
Format string of the indicator for files to be cut.
|
Format string of the indicator for files to be cut.
|
||||||
.SS dircache (bool) (default true)
|
|
||||||
Cache directory contents.
|
|
||||||
.SS dircounts (bool) (default false)
|
.SS dircounts (bool) (default false)
|
||||||
When this option is enabled, directory sizes show the number of items
|
When this option is enabled, directory sizes show the number of items
|
||||||
inside instead of the total size of the directory, which needs to be
|
inside instead of the total size of the directory, which needs to be
|
||||||
|
|||||||
@@ -573,42 +573,34 @@ type nav struct {
|
|||||||
jumpListInd int
|
jumpListInd int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) loadDirInternal(path string) *dir {
|
|
||||||
d := &dir{
|
|
||||||
loading: true,
|
|
||||||
path: path,
|
|
||||||
sortby: getSortBy(path),
|
|
||||||
dircounts: getDirCounts(path),
|
|
||||||
dirfirst: getDirFirst(path),
|
|
||||||
dironly: getDirOnly(path),
|
|
||||||
hidden: getHidden(path),
|
|
||||||
reverse: getReverse(path),
|
|
||||||
locale: getLocale(path),
|
|
||||||
visualAnchor: -1,
|
|
||||||
hiddenfiles: gOpts.hiddenfiles,
|
|
||||||
ignorecase: gOpts.ignorecase,
|
|
||||||
ignoredia: gOpts.ignoredia,
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
nav.dirChan <- newDir(path)
|
|
||||||
}()
|
|
||||||
return d
|
|
||||||
}
|
|
||||||
|
|
||||||
func (nav *nav) loadDir(path string) *dir {
|
func (nav *nav) loadDir(path string) *dir {
|
||||||
if gOpts.dircache {
|
d, ok := nav.dirCache[path]
|
||||||
d, ok := nav.dirCache[path]
|
if !ok {
|
||||||
if !ok {
|
go func() {
|
||||||
d = nav.loadDirInternal(path)
|
nav.dirChan <- newDir(path)
|
||||||
nav.dirCache[path] = d
|
}()
|
||||||
return d
|
|
||||||
|
d := &dir{
|
||||||
|
loading: true,
|
||||||
|
path: path,
|
||||||
|
sortby: getSortBy(path),
|
||||||
|
dircounts: getDirCounts(path),
|
||||||
|
dirfirst: getDirFirst(path),
|
||||||
|
dironly: getDirOnly(path),
|
||||||
|
hidden: getHidden(path),
|
||||||
|
reverse: getReverse(path),
|
||||||
|
locale: getLocale(path),
|
||||||
|
visualAnchor: -1,
|
||||||
|
hiddenfiles: gOpts.hiddenfiles,
|
||||||
|
ignorecase: gOpts.ignorecase,
|
||||||
|
ignoredia: gOpts.ignoredia,
|
||||||
}
|
}
|
||||||
|
nav.dirCache[path] = d
|
||||||
nav.checkDir(d)
|
|
||||||
|
|
||||||
return d
|
return d
|
||||||
}
|
}
|
||||||
return nav.loadDirInternal(path)
|
|
||||||
|
nav.checkDir(d)
|
||||||
|
return d
|
||||||
}
|
}
|
||||||
|
|
||||||
func (nav *nav) checkDir(dir *dir) {
|
func (nav *nav) checkDir(dir *dir) {
|
||||||
|
|||||||
@@ -53,7 +53,6 @@ var gOpts struct {
|
|||||||
cursorparentfmt string
|
cursorparentfmt string
|
||||||
cursorpreviewfmt string
|
cursorpreviewfmt string
|
||||||
cutfmt string
|
cutfmt string
|
||||||
dircache bool
|
|
||||||
dircounts bool
|
dircounts bool
|
||||||
dirfirst bool
|
dirfirst bool
|
||||||
dironly bool
|
dironly bool
|
||||||
@@ -221,7 +220,6 @@ func init() {
|
|||||||
gOpts.cursorparentfmt = "\033[7m"
|
gOpts.cursorparentfmt = "\033[7m"
|
||||||
gOpts.cursorpreviewfmt = "\033[4m"
|
gOpts.cursorpreviewfmt = "\033[4m"
|
||||||
gOpts.cutfmt = "\033[7;31m"
|
gOpts.cutfmt = "\033[7;31m"
|
||||||
gOpts.dircache = true
|
|
||||||
gOpts.dircounts = false
|
gOpts.dircounts = false
|
||||||
gOpts.dirfirst = true
|
gOpts.dirfirst = true
|
||||||
gOpts.dironly = false
|
gOpts.dironly = false
|
||||||
|
|||||||
Reference in new issue
Block a user