fix: avoid passing .git directories to on-load (#2382)

* fix: avoid passing `.git` directories to `on-load`

* docs: update `CHANGELOG.md`
This commit is contained in:
CatsDeservePets authored and GitHub committed 2026-02-10 02:00:43 +01:00
1 parent 3a0b538d8b
commit 4b8281ea86
2 files changed
+11 -4

No files matched your search

+1
View File
@@ -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). - Previews are now correctly updated on `visual-change` (#2373).
- The `dircounts` indicator for errors is changed back to `!` instead of `?` (#2372). - 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 `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) ## [r41](https://github.com/gokcehan/lf/releases/tag/r41)
+10 -4
View File
@@ -414,11 +414,17 @@ func (app *app) loop() {
app.watchDir(d) app.watchDir(d)
paths := []string{} // Avoid flickering UI and multiple, unnecessary `on-load` calls
for _, file := range d.allFiles { // triggered by Git commands executed inside the users `on-load`
paths = append(paths, file.path) // 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 { if d.path == app.nav.currDir().path {
app.nav.preload() app.nav.preload()