fix: detection of case in find mode should use case folding

It was using is_lowercase, which only returns true for lowercase
alpha characters and not other caseless symbols line numeric digits.

Now we check that case_fold is a no-op instead. This has semantics
that better match user expectations as case folding is also used in
the actual search.

closes #460
This commit is contained in:
CJ van den Berg 2026-01-21 10:13:58 +01:00
parent ee37dc8730
commit 331538de36
Signed by: neurocyte
GPG key ID: 8EB1E1BB660E3FB9

View file

@ -13,6 +13,7 @@ const ed = @import("../../editor.zig");
const Allocator = @import("std").mem.Allocator; const Allocator = @import("std").mem.Allocator;
const eql = @import("std").mem.eql; const eql = @import("std").mem.eql;
const ArrayList = @import("std").ArrayList; const ArrayList = @import("std").ArrayList;
const Writer = @import("std").Io.Writer;
const Self = @This(); const Self = @This();
const name = "󱎸 find"; const name = "󱎸 find";
@ -130,7 +131,10 @@ fn flush_input(self: *Self) !void {
} }
fn auto_detect_mode(self: *Self) Buffer.FindMode { fn auto_detect_mode(self: *Self) Buffer.FindMode {
return if (Buffer.unicode.is_lowercase(self.input_.items)) .case_folded else .exact; const pattern = self.input_.items;
const folded = Buffer.unicode.case_fold(self.allocator, pattern) catch return .case_folded;
defer self.allocator.free(folded);
return if (eql(u8, pattern, folded)) .case_folded else .exact;
} }
fn cmd(self: *Self, name_: []const u8, ctx: command.Context) tp.result { fn cmd(self: *Self, name_: []const u8, ctx: command.Context) tp.result {