Refactor pager commands & synchronous shell commands (no-op) (#1243)

* Refactor piping to pager: extract to separate function, simplify invocation

This is meant to be straightforward and clearly a no-op,\
at the cost of being a bit verbose.

* Refactor: reduce duplication between sync shell commands and pager

* Refactor: minor cleanup of async shell functions

After the previous refactors, the logic for async shell commands can
be simplified somewhat. There is likely room for further improvements,
but that is beyond the scope of this PR.

* Remove duplicated shellSetPG invocation

See https://github.com/gokcehan/lf/pull/1243#discussion_r1193078282
This commit is contained in:
Ilya Grigoriev authored and GitHub committed 2023-05-21 15:08:49 +03:00
1 parent 5bf78dc087
commit 346c439f76
2 files changed
+60 -74

No files matched your search

+3 -12
View File
@@ -2504,20 +2504,11 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.cmdAccLeft = acc
update(app)
case "maps":
cleanUp := app.runShell(envPager, nil, "$|")
io.Copy(app.cmdIn, listBinds(gOpts.keys))
app.cmdIn.Close()
cleanUp()
app.runPagerOnText(listBinds(gOpts.keys))
case "cmaps":
cleanUp := app.runShell(envPager, nil, "$|")
io.Copy(app.cmdIn, listBinds(gOpts.cmdkeys))
app.cmdIn.Close()
cleanUp()
app.runPagerOnText(listBinds(gOpts.cmdkeys))
case "jumps":
cleanUp := app.runShell(envPager, nil, "$|")
io.Copy(app.cmdIn, listJumps(app.nav.jumpList, app.nav.jumpListInd))
app.cmdIn.Close()
cleanUp()
app.runPagerOnText(listJumps(app.nav.jumpList, app.nav.jumpListInd))
default:
cmd, ok := gOpts.cmds[e.name]
if !ok {