Skip to content

Commit

Permalink
Improve refreshing of file statinfo (gokcehan#1536)
Browse files Browse the repository at this point in the history
  • Loading branch information
joelim-work authored Dec 26, 2023
1 parent e1ab725 commit 12ce649
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ func (app *app) loop() {
if err == nil {
if d.path == app.nav.currDir().path {
app.ui.loadFile(app, true)
if app.ui.msg == "" {
if app.ui.msgIsStat {
app.ui.loadFileInfo(app.nav)
}
}
Expand Down
3 changes: 1 addition & 2 deletions eval.go
Original file line number Diff line number Diff line change
Expand Up @@ -1960,8 +1960,7 @@ func (e *callExpr) eval(app *app, args []string) {
app.ui.echoerrf("reload: %s", err)
}
app.ui.loadFile(app, true)
// clear file information, will be loaded asynchronously
app.ui.msg = ""
app.ui.loadFileInfo(app.nav)
case "read":
if app.ui.cmdPrefix == ">" {
return
Expand Down
10 changes: 7 additions & 3 deletions ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,7 @@ type ui struct {
msgWin *win
menuWin *win
msg string
msgIsStat bool
regPrev *reg
dirPrev *dir
exprChan chan expr
Expand Down Expand Up @@ -598,6 +599,7 @@ func newUI(screen tcell.Screen) *ui {
promptWin: newWin(wtot, 1, 0, 0),
msgWin: newWin(wtot, 1, 0, htot-1),
menuWin: newWin(wtot, 1, 0, htot-2),
msgIsStat: true,
exprChan: make(chan expr, 1000),
keyChan: make(chan string, 1000),
tevChan: make(chan tcell.Event, 1000),
Expand Down Expand Up @@ -655,10 +657,11 @@ func (ui *ui) sort() {

func (ui *ui) echo(msg string) {
ui.msg = msg
ui.msgIsStat = false
}

func (ui *ui) echomsg(msg string) {
ui.msg = msg
ui.echo(msg)
log.Print(msg)
}

Expand All @@ -671,7 +674,7 @@ func optionToFmtstr(optstr string) string {
}

func (ui *ui) echoerr(msg string) {
ui.msg = fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg)
ui.echo(fmt.Sprintf(optionToFmtstr(gOpts.errorfmt), msg))
log.Printf("error: %s", msg)
}

Expand Down Expand Up @@ -756,7 +759,8 @@ func (ui *ui) loadFileInfo(nav *nav) {
}
}

ui.echo(fileInfo)
ui.msg = fileInfo
ui.msgIsStat = true
}

func (ui *ui) drawPromptLine(nav *nav) {
Expand Down

0 comments on commit 12ce649

Please sign in to comment.