fix: avoid surprising case changes in completions (#2336)

This commit is contained in:
CatsDeservePets authored and GitHub committed 2026-01-03 00:44:12 +01:00
1 parent e1016bbd74
commit 57f6ade1b7
2 files changed
+6 -2

No files matched your search

+1
View File
@@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
- A bug where sixel images fail to display when scrolling back and forth is now fixed (#2301).
- Newline characters are now ignored when drawing the ruler with the `ruler` file configured (#2319).
- A potential crash when using the `scroll-up`/`scroll-down` commands is now fixed (#2320).
- Case-insensitive command-line completions no longer cause user input to be displayed in lowercase (#2336).
## [r40](https://github.com/gokcehan/lf/releases/tag/r40)
+5 -2
View File
@@ -282,7 +282,9 @@ func matchFile(s string, dirOnly bool, escape, unescape func(string) string) (ma
if len(matches) == 1 {
commonName = name
} else {
commonName = commonPrefix(strings.ToLower(commonName), strings.ToLower(name))
// Match case-insensitively without changing the prefix's case.
p := commonPrefix(strings.ToLower(commonName), strings.ToLower(name))
commonName = string([]rune(commonName)[:len([]rune(p))])
}
}
@@ -388,7 +390,8 @@ func matchSearch(s string) (matches []compMatch, result string) {
if len(matches) == 1 {
result = f.Name()
} else {
result = commonPrefix(strings.ToLower(result), strings.ToLower(f.Name()))
p := commonPrefix(strings.ToLower(result), strings.ToLower(f.Name()))
result = string([]rune(result)[:len([]rune(p))])
}
}