refactor(hooks): simplify regex pool entry

This commit is contained in:
Tianyi Cui
2026-07-29 20:58:28 +08:00
parent c7076e15b8
commit 4997846e45
+3 -3
View File
@@ -14,8 +14,8 @@ import type { RRegex as RustRegex } from 'rregex'
import type { MatcherMode } from './types.ts'
type CodexRegexPoolEntry =
| { regex: RustRegex; diagnostic?: never }
| { regex?: never; diagnostic: string }
| { regex: RustRegex }
| { diagnostic: string }
type RRegexModule = {
RRegex: new(pattern: string) => RustRegex
@@ -98,7 +98,7 @@ function compileMatcher(matcher: string | undefined, mode: MatcherMode): Compile
if (mode === 'codex') {
const entry = internCodexRegex(pattern)
if (entry.regex !== undefined) {
if ('regex' in entry) {
const regex = entry.regex
return { matches: query => regex.isMatch(query) }
}