Paste the path of a file dropped on the window - #22
Merged
Merged
Conversation
Showing an agent a file meant typing its path out. Drag one onto the window and the path is typed into the session instead, followed by a space, so several dropped together line up as arguments. While a file is over the window the bottom bar says what will happen. Paths that need it are wrapped in single quotes — a space in a name would otherwise split into two arguments, and a quote or a semicolon in one is worse than that. Single quotes inside are closed and rejoined the usual way. Plain paths are passed through untouched so the common case stays readable. If the program has bracketed paste on, the path arrives as pasted text rather than as typing. Follows what orca does for its agent prompt, which is where the request came from. Adds six tests: plain paths pass through, spaces are quoted, an embedded single quote is rejoined, nine kinds of character the shell would act on are quoted, a Japanese path is quoted, and an empty path becomes an empty argument. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01GvMacYD6T9EoWqc7C247Hr
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Showing an agent a file meant typing its path out. Drag one onto the window and
the path is typed into the session instead, followed by a space, so several
dropped together line up as arguments. While a file is over the window the
bottom bar says what will happen.
This follows what orca does for its agent
prompt — "drag files or images straight into an agent prompt" — which is
where the request came from.
Quoting
Paths that need it are wrapped in single quotes. A space in a name would
otherwise split into two arguments, and a quote or a semicolon in one is worse
than that:
/Users/tkc/a.txt/Users/tkc/a.txt/Users/tkc/My Documents/a.txt'/Users/tkc/My Documents/a.txt'/tmp/it's here'/tmp/it'\''s here'/tmp/資料.txt'/tmp/資料.txt'Plain paths pass through untouched so the common case stays readable. If the
program has bracketed paste on, the path arrives as pasted text rather than as
typing.
Testing
Six new tests, 194 total: plain paths pass through, spaces are quoted, an
embedded single quote is closed and rejoined, nine kinds of character the shell
would act on (
;$( )backticks&|>*\") are quoted, aJapanese path is quoted, and an empty path becomes an empty argument.
🤖 Generated with Claude Code
https://claude.ai/code/session_01GvMacYD6T9EoWqc7C247Hr