Compare commits

..

2 commits

2 changed files with 16 additions and 2 deletions

View file

@ -1039,9 +1039,19 @@ const Node = union(enum) {
}
}
};
const pattern_ = switch (mode) {
.exact => pattern,
.case_folded => unicode.case_fold(allocator, pattern) catch
allocator.dupe(u8, pattern) catch
@panic("OOM find_all_ranges"),
};
defer switch (mode) {
.exact => {},
.case_folded => allocator.free(pattern_),
};
var ctx: Ctx = .{
.allocator = allocator,
.pattern = pattern,
.pattern = pattern_,
.data = data,
.callback = callback,
.buf = try allocator.alloc(u8, pattern.len * 2),

View file

@ -180,7 +180,11 @@ const cmds = struct {
pub fn toggle_find_mode(self: *Self, _: Ctx) Result {
const new_find_mode: Buffer.FindMode = switch (self.find_mode) {
.exact => .case_folded,
.auto, .case_folded => .exact,
.case_folded => .exact,
.auto => if (Buffer.unicode.is_lowercase(self.input_.items))
.exact
else
.case_folded,
};
const allocator = self.allocator;
const query = try allocator.dupe(u8, self.input_.items);