From 4b8281ea86fc5ca597d71b32fd15baf7c65ef9d2 Mon Sep 17 00:00:00 2001 From: CatsDeservePets <145048791+CatsDeservePets@users.noreply.github.com> Date: Tue, 10 Feb 2026 02:00:43 +0100 Subject: [PATCH] fix: avoid passing `.git` directories to `on-load` (#2382) * fix: avoid passing `.git` directories to `on-load` * docs: update `CHANGELOG.md` --- CHANGELOG.md | 1 + app.go | 14 ++++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5a41a8bc..2838d292 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,6 +20,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), - Previews are now correctly updated on `visual-change` (#2373). - The `dircounts` indicator for errors is changed back to `!` instead of `?` (#2372). - The `select` command can now select files immediately after creation as part of a script (#2377). +- The `on-load` hook command now ignores `.git` directories by default to avoid flicker and repeated `on-load` triggers. ## [r41](https://github.com/gokcehan/lf/releases/tag/r41) diff --git a/app.go b/app.go index 23df125f..a4b71517 100644 --- a/app.go +++ b/app.go @@ -414,11 +414,17 @@ func (app *app) loop() { app.watchDir(d) - paths := []string{} - for _, file := range d.allFiles { - paths = append(paths, file.path) + // Avoid flickering UI and multiple, unnecessary `on-load` calls + // triggered by Git commands executed inside the users `on-load` + // command (often used to add git symbols using `addcustominfo`). + // TODO: Should `watch` also ignore `.git` directories? + if filepath.Base(d.path) != ".git" { + paths := make([]string, len(d.allFiles)) + for i, file := range d.allFiles { + paths[i] = file.path + } + onLoad(app, paths) } - onLoad(app, paths) if d.path == app.nav.currDir().path { app.nav.preload()