handle relative paths in 'toggle' command

This commit is contained in:
Gokcehan 2020-07-20 02:22:31 +03:00
parent 7174b7e307
commit 9539daf8df

View File

@ -711,11 +711,15 @@ func (e *callExpr) eval(app *app, args []string) {
if len(e.args) == 0 { if len(e.args) == 0 {
app.nav.toggle() app.nav.toggle()
} else { } else {
curr := app.nav.currDir()
for _, path := range e.args { for _, path := range e.args {
if _, err := os.Lstat(path); err == nil { if !filepath.IsAbs(path) {
path = filepath.Join(curr.path, path)
}
if _, err := os.Lstat(path); !os.IsNotExist(err) {
app.nav.toggleSelection(path) app.nav.toggleSelection(path)
} else { } else {
log.Printf("toggle: %s", err) app.ui.echoerrf("toggle: %s", err)
} }
} }
} }