From 930364ce7864d21fa70cd4214330886c953a42f1 Mon Sep 17 00:00:00 2001 From: Gokcehan Date: Sat, 22 Jan 2022 16:57:28 +0300 Subject: [PATCH] Revert "dirtyfiles: files that don't require cleaning before previewing them (#729)" This reverts commit 673dad9f070edd86494232232c620058d49ba5ef. --- app.go | 1 - complete.go | 1 - doc.go | 9 --------- docstring.go | 10 ---------- eval.go | 18 ------------------ lf.1 | 7 ------- nav.go | 29 ++++------------------------- opts.go | 2 -- 8 files changed, 4 insertions(+), 73 deletions(-) diff --git a/app.go b/app.go index 3dd8d72..4b80278 100644 --- a/app.go +++ b/app.go @@ -481,7 +481,6 @@ func (app *app) runShell(s string, args []string, prefix string) { cmd.Stderr = os.Stderr app.nav.previewChan <- "" - app.nav.previewChan <- "!" if err := app.ui.suspend(); err != nil { log.Printf("suspend: %s", err) } diff --git a/complete.go b/complete.go index 6ccccb5..00ed30c 100644 --- a/complete.go +++ b/complete.go @@ -87,7 +87,6 @@ var ( "dironly", "nodironly", "dironly!", - "dirtyfiles", "drawbox", "nodrawbox", "drawbox!", diff --git a/doc.go b/doc.go index 4f6a742..3e180da 100644 --- a/doc.go +++ b/doc.go @@ -105,7 +105,6 @@ The following options can be used to customize the behavior of lf: dircounts bool (default off) dirfirst bool (default on) dironly bool (default off) - dirtyfiles []string (default '!*') drawbox bool (default off) errorfmt string (default "\033[7;31;47m%s\033[0m") filesep string (default "\n") @@ -535,14 +534,6 @@ Show directories first above regular files. Show only directories. - dirtyfiles []string (default '!*') - -List of dirty file glob patterns. -These files won't have 'cleaner' executed before previewing them. -Patterns can be given as relative or absolute paths. -Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. -In addition, if a pattern starts with '!', then its matches are excluded from dirty files. - drawbox bool (default off) Draw boxes around panes with box drawing characters. diff --git a/docstring.go b/docstring.go index 0f08f21..cd100dc 100644 --- a/docstring.go +++ b/docstring.go @@ -109,7 +109,6 @@ The following options can be used to customize the behavior of lf: dircounts bool (default off) dirfirst bool (default on) dironly bool (default off) - dirtyfiles []string (default '!*') drawbox bool (default off) errorfmt string (default "\033[7;31;47m%s\033[0m") filesep string (default "\n") @@ -566,15 +565,6 @@ Show directories first above regular files. Show only directories. - dirtyfiles []string (default '!*') - -List of dirty file glob patterns. These files won't have 'cleaner' executed -before previewing them. Patterns can be given as relative or absolute paths. -Globbing supports the usual special characters, '*' to match any sequence, -'?' to match any character, and '[...]' or '[^...] to match character sets -or ranges. In addition, if a pattern starts with '!', then its matches are -excluded from dirty files. - drawbox bool (default off) Draw boxes around panes with box drawing characters. diff --git a/eval.go b/eval.go index 03eeac4..6dd87b6 100644 --- a/eval.go +++ b/eval.go @@ -68,24 +68,6 @@ func (e *setExpr) eval(app *app, args []string) { gOpts.sortType.option ^= dirfirstSort app.nav.sort() app.ui.sort() - case "dirtyfiles": - toks := strings.Split(e.val, ":") - for _, s := range toks { - if s == "" { - app.ui.echoerr("dirtyfiles: glob should be non-empty") - return - } - _, err := filepath.Match(s, "a") - if err != nil { - app.ui.echoerrf("dirtyfiles: %s", err) - return - } - } - gOpts.dirtyfiles = toks - app.nav.sort() - app.nav.position() - app.ui.sort() - app.ui.loadFile(app.nav, true) case "drawbox": gOpts.drawbox = true app.ui.renew() diff --git a/lf.1 b/lf.1 index 1678307..b2117e9 100644 --- a/lf.1 +++ b/lf.1 @@ -124,7 +124,6 @@ The following options can be used to customize the behavior of lf: dircounts bool (default off) dirfirst bool (default on) dironly bool (default off) - dirtyfiles []string (default '!*') drawbox bool (default off) errorfmt string (default "\e033[7;31;47m%s\e033[0m") filesep string (default "\en") @@ -663,12 +662,6 @@ Show directories first above regular files. .PP Show only directories. .PP -.EX - dirtyfiles []string (default '!*') -.EE -.PP -List of dirty file glob patterns. These files won't have 'cleaner' executed before previewing them. Patterns can be given as relative or absolute paths. Globbing supports the usual special characters, '*' to match any sequence, '?' to match any character, and '[...]' or '[^...] to match character sets or ranges. In addition, if a pattern starts with '!', then its matches are excluded from dirty files. -.PP .EX drawbox bool (default off) .EE diff --git a/nav.go b/nav.go index a69bb1f..815e18e 100644 --- a/nav.go +++ b/nav.go @@ -115,7 +115,6 @@ type dir struct { sortType sortType // sort method and options from last sort dironly bool // dironly value from last sort hiddenfiles []string // hiddenfiles value from last sort - dirtyfiles []string // files that don't require cleaning filter []string // last filter for this directory ignorecase bool // ignorecase value from last sort ignoredia bool // ignoredia value from last sort @@ -155,7 +154,6 @@ func (dir *dir) sort() { dir.sortType = gOpts.sortType dir.dironly = gOpts.dironly dir.hiddenfiles = gOpts.hiddenfiles - dir.dirtyfiles = gOpts.dirtyfiles dir.ignorecase = gOpts.ignorecase dir.ignoredia = gOpts.ignoredia @@ -363,7 +361,6 @@ func (nav *nav) loadDirInternal(path string) *dir { path: path, sortType: gOpts.sortType, hiddenfiles: gOpts.hiddenfiles, - dirtyfiles: gOpts.dirtyfiles, ignorecase: gOpts.ignorecase, ignoredia: gOpts.ignoredia, } @@ -525,26 +522,21 @@ func (nav *nav) previewLoop(ui *ui) { var prev string for path := range nav.previewChan { clear := len(path) == 0 - forceClear := path == "!" loop: for { select { case path = <-nav.previewChan: clear = clear || len(path) == 0 - forceClear = forceClear || path == "!" default: break loop } } - dir := nav.currDir() if clear && len(gOpts.previewer) != 0 && len(gOpts.cleaner) != 0 && nav.volatilePreview { - if forceClear || !isDirty(dir.files[dir.ind], dir.path, dir.dirtyfiles) { - cmd := exec.Command(gOpts.cleaner, prev) - if err := cmd.Run(); err != nil { - log.Printf("cleaning preview: %s", err) - } - nav.volatilePreview = false + cmd := exec.Command(gOpts.cleaner, prev) + if err := cmd.Run(); err != nil { + log.Printf("cleaning preview: %s", err) } + nav.volatilePreview = false } if len(path) != 0 { win := ui.wins[len(ui.wins)-1] @@ -554,19 +546,6 @@ func (nav *nav) previewLoop(ui *ui) { } } -func isDirty(f os.FileInfo, path string, dirtyfiles []string) bool { - dirty := false - for _, pattern := range dirtyfiles { - matched := matchPattern(strings.TrimPrefix(pattern, "!"), f.Name(), path) - if strings.HasPrefix(pattern, "!") && matched { - dirty = false - } else if matched { - dirty = true - } - } - return dirty -} - func matchPattern(pattern, name, path string) bool { s := name diff --git a/opts.go b/opts.go index eb04b64..724c93d 100644 --- a/opts.go +++ b/opts.go @@ -65,7 +65,6 @@ var gOpts struct { truncatechar string ratios []int hiddenfiles []string - dirtyfiles []string info []string shellopts []string keys map[string]expr @@ -112,7 +111,6 @@ func init() { gOpts.truncatechar = "~" gOpts.ratios = []int{1, 2, 3} gOpts.hiddenfiles = []string{".*"} - gOpts.dirtyfiles = []string{"!*"} gOpts.info = nil gOpts.shellopts = nil gOpts.sortType = sortType{naturalSort, dirfirstSort}