gokcehan/lf

Normalize arguments unused

Closed this issue · 2 comments

It seems that the boolean arguments are left completely unused in favor of what's in gOpts. I am not sure whether the intended behavior here is to always use what's in gOpts, to always use what's passed in, or some hybrid behavior but as-is these arguments can be completely removed without changing any behavior.

lf/nav.go

Lines 199 to 209 in 6abce04

func normalize(s1, s2 string, ignorecase, ignoredia bool) (string, string) {
if gOpts.ignorecase {
s1 = strings.ToLower(s1)
s2 = strings.ToLower(s2)
}
if gOpts.ignoredia {
s1 = removeDiacritics(s1)
s2 = removeDiacritics(s2)
}
return s1, s2
}

Good point. Judging by the callers, I think the intention here was to take into account the directory-specific options for ignorecase and ignoredia, as in #1381. I'm not very familiar with that PR, though, so I'm not sure which behavior would be correct.

Looking through the commit history, it looks like it comes from c629b3d, which is attempt to reduce usage of global variables since dir.sort() can be called from multiple threads. I think it's just a mistake and the intention was to use the passed in ignorecase and ignoredia instead of the global values.