lf: (BUG) The bottom status bar is not updated

The authorization list of files and directories does not change, even if I use the reload command. Here is the example command I created:

cmd change_permission ${{
	clear
	set -f
	printf "New permission -> "
	read perm
    for f in $fx; do
        sudo -A chmod "$perm" "$f"
    done
    lf -remote "send reload"
    lf -remote "send unselect"
    lf -remote "send clear"
}}

Even if I use the reload command, the lower status shows the old authorization, while the color of the file changes according to the authorization. If I move the cursor back and forth, the authorization display on the lower status bar is also updated.

About this issue

  • Original URL
  • State: closed
  • Created a year ago
  • Comments: 15

Most upvoted comments

Yes. Both of them address all the reload cases I could think of, so you can use whichever one you prefer.

Hi @DusanLesan

Here you go, apologies in advance for the large wall of text that follows 😛


Solution 1:

Remove the if app.ui.msg == "" condition in step 3. But this could cause an undesirable side effect where app.ui.msg is updated unconditionally (potentially wiping out something like an error message) whenever an asynchronous reload happens.

Checkout this branch: https://github.com/joelim-work/lf/tree/reload-status-bar-1

--- a/app.go
+++ b/app.go
@@ -414,9 +414,7 @@ func (app *app) loop() {
                        if err == nil {
                                if d.path == app.nav.currDir().path {
                                        app.ui.loadFile(app, true)
-                                       if app.ui.msg == "" {
-                                               app.ui.loadFileInfo(app.nav)
-                                       }
+                                       app.ui.loadFileInfo(app.nav)
                                }
                                if d.path == curr.path {
                                        app.ui.dirPrev = d

I have found that removing the if app.ui.msg == "" condition and updating the status bar unconditionally may be undesirable. For instance try the following scenario:

  1. Start lf and trigger an error message (e.g. unknown mapping by typing some unbound key)
  2. Start a new terminal, and modify the current directory (you can touch the directory, or create a new file in it)
  3. Without switching back to lf, force it to load (you can run lf -remote 'send load', I have also gotten this to work by configuring set period 1)
  4. The error message from step 1 should be wiped out and replaced with the updated file information, even without doing anything in lf, which users could find annoying.

Solution 2:

Clear app.ui.msg instead of calling loadFileInfo in step 2, which means the if app.ui.msg == "" condition will end up being true. I think this approach is safer.

Checkout this branch: https://github.com/joelim-work/lf/tree/reload-status-bar-2

--- a/eval.go
+++ b/eval.go
@@ -1312,7 +1312,7 @@ func (e *callExpr) eval(app *app, args []string) {
                        app.ui.echoerrf("reload: %s", err)
                }
                app.ui.loadFile(app, true)
-               app.ui.loadFileInfo(app.nav)
+               app.ui.msg = ""
        case "read":
                if app.ui.cmdPrefix == ">" {
                        return

This approach keeps the if app.ui.msg == "" condition so that error messages won’t get wiped out. I haven’t found any downsides with this approach, other than the fact that it is kind of a hack to clear app.ui.msg just to satisfy that condition when the directory is reloaded.

Okay, reopened.

Ohh, working, thank you! 😃