lf icon indicating copy to clipboard operation
lf copied to clipboard

[Feature request] Support `ignorecase false` and `smartcase` at same time

Open ysl2 opened this issue 4 months ago • 3 comments

Currently, the smartcase only available when ignorecase true. However, I hope the smartcase can work with ignorecase false.

ysl2 avatar Aug 21 '25 16:08 ysl2

I'm not sure what you mean here. smartcase forces matching to be case-sensitive if the pattern contains an uppercase character, so if ignorecase is disabled then the matching is already case-sensitive and there is nothing for smartcase to do.

joelim-work avatar Aug 22 '25 01:08 joelim-work

Sorry, I will clearify my thought.

I want lf don't ignore case when sorting, but ignore case when searching...

So I hope the ignorecase and smartcase can be independent.

ysl2 avatar Aug 22 '25 03:08 ysl2

Okay I see, so the problem isn't to do with smartcase, it's to do with the fact that ignorecase affects both sorting and searching. I think users normally expect the behavior to be the same (either both case-sensitive, or both case-insensitive) for both sorting and searching, but you can try sorting by a custom method, see #618 for more details.

EDIT: You can try something like below, I only tested it briefly though.

# uncomment for debugging
# set info custom

set sortby custom

cmd on-load &{{
    cmds() {
        find "$(dirname "$1")" -mindepth 1 -maxdepth 1 \
            | LC_ALL=C sort \
            | nl -n rz -s '|' \
            | while IFS='|' read -r index file; do
            printf 'addcustominfo "%s" "%s"; ' "$file" "$index"
        done
    }

    lf -remote "send $id :$(cmds "$@")"
}}

joelim-work avatar Aug 22 '25 04:08 joelim-work