Fixed command substitutions not expanding when used as a command name

This commit is contained in:
2026-02-23 23:32:12 -05:00
parent 06a55734c9
commit fa49e2ef70
4 changed files with 201 additions and 185 deletions

View File

@@ -184,14 +184,16 @@ impl Highlighter {
input_chars.next();
}
let inner_clean = Self::strip_markers(&inner);
// Determine prefix from content (handles both <( and >( for proc subs)
let prefix = match ch {
markers::CMD_SUB => "$(",
markers::SUBSH => "(",
markers::PROC_SUB => {
if inner.starts_with("<(") {
if inner_clean.starts_with("<(") {
"<("
} else if inner.starts_with(">(") {
} else if inner_clean.starts_with(">(") {
">("
} else {
"<("
@@ -199,14 +201,13 @@ impl Highlighter {
}
_ => unreachable!(),
};
let inner_content = if incomplete {
inner.strip_prefix(prefix).unwrap_or(&inner)
inner_clean.strip_prefix(prefix).unwrap_or(&inner_clean)
} else {
inner
inner_clean
.strip_prefix(prefix)
.and_then(|s| s.strip_suffix(")"))
.unwrap_or(&inner)
.unwrap_or(&inner_clean)
};
let mut recursive_highlighter = Self::new();