Skip to content

Conversation

bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Oct 17, 2025

ParsedCommand::Read has a name field that attempts to identify the name of the file being read, but the file may not be in the cwd in which the command is invoked as demonstrated by this existing unit test:

#[test]
fn supports_cat_sed_n() {
let inner = "cat tui/Cargo.toml | sed -n '1,200p'";
assert_parsed(
&vec_str(&["bash", "-lc", inner]),
vec![ParsedCommand::Read {
cmd: inner.to_string(),
name: "Cargo.toml".to_string(),
}],
);
}

As you can see, tui/Cargo.toml is the relative path to the file being read.

This PR introduces a new path: PathBuf field to ParsedCommand::Read that attempts to capture this information. When possible, this is an absolute path, though when relative, it should be resolved against the cwd that will be used to run the command to derive the absolute path.

This should make it easier for clients to provide UI for a "read file" event that corresponds to the command execution.

@bolinfest bolinfest enabled auto-merge (squash) October 17, 2025 06:10
@bolinfest bolinfest merged commit 50f53e7 into main Oct 17, 2025
20 checks passed
@bolinfest bolinfest deleted the bolinfest/parsed-command-read-path-field branch October 17, 2025 06:19
@github-actions github-actions bot locked and limited conversation to collaborators Oct 17, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants