Skip to content

macos: ignore -e arguments as open files - #13748

Merged
mitchellh merged 1 commit into
mainfrom
macos-e
Aug 11, 2026
Merged

mitchellh merged 1 commit into
mainfrom
macos-e

Conversation

@mitchellh

Copy link
Copy Markdown
Contributor

Fixes #13319

AppKit treats existing positional arguments as documents, causing paths passed to a child command after -e to open an extra terminal surface.

We now process args ourselves during openFile callbacks to ignore file paths after -e. There isn't a way to avoid this I can find because AppKit processes argc/argv from the main entrypoint and that can't be overridden.

Fixes #13319

AppKit treats existing positional arguments as documents, causing paths
passed to a child command after -e to open an extra terminal surface.

We now process args ourselves during openFile callbacks to ignore 
file paths after `-e`. There isn't a way to avoid this I can find
because AppKit processes argc/argv from the main entrypoint and that
can't be overridden.
@mitchellh mitchellh added this to the 1.4.0 milestone Aug 11, 2026
@mitchellh
mitchellh requested a review from a team as a code owner August 11, 2026 15:30
@ghostty-bot ghostty-bot Bot added the os/macos label Aug 11, 2026
fileExists: { existing.contains($0) }
)

#expect(!filter.shouldIgnore("/tmp/before.txt"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw this is intentional right now. I couldn't find evidence in any terminal really how this should be handled. I think its harmless.

/// `-e`. Each matching event is consumed once so later requests to open the same
/// file are handled normally.
final class CommandLineOpenFileFilter {
private let workingDirectory: String

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is fine, but we should also consider using the URL-based file system paths more often.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense generally. Since the surrounding AppKit and FileManager APIs use path strings here, I’d prefer to keep this change as-is. I don't think URL buys us anything?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in this case because the inputs are already String, but the working directory could be a URL with internal conversion. (This is already doing as NSString to get the to older NSString-based path routines that are no longer available on String and have moved to URL.)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay fair enough, did this: 8c9fd7a

@mitchellh
mitchellh merged commit a858bd4 into main Aug 11, 2026
205 checks passed
@mitchellh
mitchellh deleted the macos-e branch August 11, 2026 16:04
mitchellh added a commit that referenced this pull request Aug 11, 2026
#13319
#13748

Normalize command-line file arguments as file URLs internally while
keeping the AppKit and FileManager string boundaries unchanged.

This handles relative paths, URL-sensitive characters, and trailing
directory separators consistently when matching duplicate open-file
events.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants