Revert "dirtyfiles: files that don't require cleaning before previewing them (#729)"

This reverts commit 673dad9f07.
This commit is contained in:
Gokcehan 2022-01-22 16:57:28 +03:00
parent 85c73978fe
commit 930364ce78
8 changed files with 4 additions and 73 deletions

1
app.go
View File

@ -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)
}

View File

@ -87,7 +87,6 @@ var (
"dironly",
"nodironly",
"dironly!",
"dirtyfiles",
"drawbox",
"nodrawbox",
"drawbox!",

9
doc.go
View File

@ -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.

View File

@ -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.

18
eval.go
View File

@ -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()

7
lf.1
View File

@ -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

21
nav.go
View File

@ -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,27 +522,22 @@ 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
}
}
if len(path) != 0 {
win := ui.wins[len(ui.wins)-1]
nav.preview(path, win)
@ -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

View File

@ -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}