Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 28 additions & 3 deletions src/discover/registry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,17 +272,15 @@ const IGNORED_PREFIXES: &[&str] = &[
"then ",
"else\n",
"else ",
"fi",
"do\n",
"do ",
"done",
"for ",
"while ",
"if ",
"case ",
];

const IGNORED_EXACT: &[&str] = &["cd", "echo", "true", "false", "wait", "pwd", "bash", "sh"];
const IGNORED_EXACT: &[&str] = &["cd", "echo", "true", "false", "wait", "pwd", "bash", "sh", "fi", "done"];

lazy_static! {
static ref REGEX_SET: RegexSet = RegexSet::new(PATTERNS).expect("invalid regex patterns");
Expand Down Expand Up @@ -699,6 +697,33 @@ mod tests {
}
}

#[test]
fn test_classify_find_not_blocked_by_fi() {
// Regression: "fi" in IGNORED_PREFIXES used to shadow "find" commands
// because "find".starts_with("fi") is true. "fi" should only match exactly.
assert_eq!(
classify_command("find . -name foo"),
Classification::Supported {
rtk_equivalent: "rtk find",
category: "Files",
estimated_savings_pct: 70.0,
status: RtkStatus::Existing,
}
);
}

#[test]
fn test_fi_still_ignored_exact() {
// Bare "fi" (shell keyword) should still be ignored
assert_eq!(classify_command("fi"), Classification::Ignored);
}

#[test]
fn test_done_still_ignored_exact() {
// Bare "done" (shell keyword) should still be ignored
assert_eq!(classify_command("done"), Classification::Ignored);
}

#[test]
fn test_split_chain_and() {
assert_eq!(split_command_chain("a && b"), vec!["a", "b"]);
Expand Down
Loading