From 2ab866d474d6c4ffb21892bcce7d3548399b0700 Mon Sep 17 00:00:00 2001 From: David Pedersen Date: Tue, 23 Jul 2019 21:33:43 +0200 Subject: [PATCH] Make prompt for delete command more descriptive (#206) This will make the prompt shown when running the delete command more descriptive. Before: `delete?[y/N]:` Now when deleting one file: `delete /tmp/abc [y/N]?` Now when deleting selection: `delete 3 items [y/N]?` --- eval.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/eval.go b/eval.go index fb657d7..2d45195 100644 --- a/eval.go +++ b/eval.go @@ -459,7 +459,7 @@ func insert(app *app, arg string) { } normal(app) - case app.ui.cmdPrefix == "delete?[y/N]: ": + case strings.HasPrefix(app.ui.cmdPrefix, "delete"): normal(app) if arg == "y" { @@ -715,11 +715,18 @@ func (e *callExpr) eval(app *app, args []string) { return } } else { - if _, err := app.nav.currFileOrSelections(); err != nil { + fileOrSelections, err := app.nav.currFileOrSelections() + + if err != nil { app.ui.echoerrf("delete: %s", err) return } - app.ui.cmdPrefix = "delete?[y/N]: " + + if selections := len(fileOrSelections); selections == 1 { + app.ui.cmdPrefix = "delete " + fileOrSelections[0] + " [y/N]? " + } else { + app.ui.cmdPrefix = "delete " + strconv.Itoa(selections) + " items [y/N]? " + } } app.ui.loadFile(app.nav) app.ui.loadFileInfo(app.nav)