From d059f648faed57f237e8866bea555c33c1d4bfe3 Mon Sep 17 00:00:00 2001 From: Guido Cella Date: Fri, 4 Apr 2025 17:23:24 +0200 Subject: [PATCH] console.lua: repurpose case_sensitive to only affect exact searches case_sensitive originally only affected Tab completion. It defaulted to yes outside of Windows just to emulate the bad defaults of bash and zsh (not fish, which has better defaults and defaults to case-insensitive completion). This was already silly, but then it affected the fuzzy autocompletion and case-sensitive fuzzy completion is even more silly. And since 0b3cc3a167, it accidentally stopped affecting even that, because the completion via script message never checked for the option. Nobody even noticed this, meaning that nobody was relying on fuzzy autocompletion being case-sensitive. Just make case_sensitive only affect the new exact search, and make it default to no on all platforms. Though IMO the search could just always be case-insensitive. --- DOCS/interface-changes/console-exact_match.txt | 1 + DOCS/man/console.rst | 4 ++-- player/lua/console.lua | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DOCS/interface-changes/console-exact_match.txt b/DOCS/interface-changes/console-exact_match.txt index d979aed26c..d465d7169d 100644 --- a/DOCS/interface-changes/console-exact_match.txt +++ b/DOCS/interface-changes/console-exact_match.txt @@ -1 +1,2 @@ add `console-exact_match` script-opt +make `console-case_sensitive` only affect exact searches and change the to default to no on platforms other than Windows diff --git a/DOCS/man/console.rst b/DOCS/man/console.rst index a636b0735b..8055f5a79b 100644 --- a/DOCS/man/console.rst +++ b/DOCS/man/console.rst @@ -206,9 +206,9 @@ Configurable Options this option, prefixing queries with ``'`` enables exact matching. ``case_sensitive`` - Default: no on Windows, yes on other platforms. + Default: no - Whether autocompletion is case sensitive. Only works with ASCII characters. + Whether exact searches are case sensitive. Only works with ASCII characters. ``history_dedup`` Default: true diff --git a/player/lua/console.lua b/player/lua/console.lua index 817f51b5f8..29e82253db 100644 --- a/player/lua/console.lua +++ b/player/lua/console.lua @@ -44,7 +44,7 @@ local opts = { selected_back_color = "#FFFFFF", match_color = "#0088FF", exact_match = false, - case_sensitive = platform ~= "windows" and true or false, + case_sensitive = false, history_dedup = true, font_hw_ratio = "auto", } @@ -452,8 +452,8 @@ local function format_grid(list, width_max, rows_max) return table.concat(rows, ass_escape("\n")), row_count end -local function fuzzy_find(needle, haystacks, case_sensitive) - local result = require "mp.fzy".filter(needle, haystacks, case_sensitive) +local function fuzzy_find(needle, haystacks) + local result = require "mp.fzy".filter(needle, haystacks) table.sort(result, function (i, j) if i[3] ~= j[3] then return i[3] > j[3]