Repository navigation
Fix macOS editor launch (os error 2) + add open_at line/column targets - #14
Merged
Merged
Conversation
…ror 2) Addresses two path-opener issues surfaced by the Annado integration (ABeehive/Annado#21). Fix (os error 2): on macOS the GUI editors (VS Code, Cursor, Sublime, Zed) are detected by their .app bundle but were launched via their CLI shim (code, subl, ...). That shim is frequently not on PATH — and a GUI-launched process inherits a stripped PATH — so open/open_with could fail with NotFound for an app detection reported as available. They now launch via `open -a "<App Name>"` (LaunchServices, PATH-independent). Feature (jump to a location): new open_at(path, app_id, &Target) and a Target { line, column } carrier for "sub-application markers". Editors that accept a Target jump via their CLI (--goto file:line:col, or a file:line:col suffix). On macOS the CLI is resolved from inside the app bundle first, then PATH, degrading to a marker-less `open -a` if neither resolves. Every other opener ignores the target and opens normally. - PathOpener.accepts_target exposes which openers honor a Target, so callers stop hardcoding the goto-capable list. - preview_command_at mirrors preview_command for targets. - Editor is modeled as a first-class internal type (CLI resolution + goto encoding + macOS open -a). Additive except: PathOpener gained accepts_target, and macOS open/open_with/preview_command now spawn `open -a` for GUI editors.
…and-macos-launch # Conflicts: # CHANGELOG.md
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.
Addresses the two
path-openerfindings from the Annado integration review (the other two findings in that PR were app-side UI polish and don't concern this crate).Fix 1 — macOS editors fail to launch with
os error 2On macOS the GUI editors are detected by their
.appbundle but were launched by their CLI shim (code,subl,cursor,zed). That shim is frequently not symlinked onto PATH (Sublime'ssublnever is by default), and a GUI-launched host (Tauri, etc.) inherits a stripped PATH — soopen/open_withcould throwNotFoundfor an app that detection reported as available.Now, on macOS, a plain open of these editors goes through
open -a "<App Name>"(LaunchServices, PATH-independent). Terminals already did this;cmuxgenuinely needs its CLI and is unchanged.Fix 2 — jump to a line (was dropped in the rewrite)
New
open_at(path, app_id, &Target)navigates to a location inside a file.Target { line, column }is a small carrier for sub-application markers, generalized so future markers (an anchor, a page, …) become new fields rather than a newopen_*per coordinate.--goto file:line:col) and Sublime, Zed (file:line:colsuffix). Modeled as a first-class internalEditortype.open -a, just without the jump.open_atis always safe to call.PathOpener.accepts_targetexposes which detected openers qualify, so callers stop hardcoding the goto-capable list.preview_command_atmirrorspreview_command.Verified on macOS (previews of the actual argv):
Compatibility
PathOpenergainedaccepts_target: bool— hand-built literals must fill it in.open/open_with/preview_commandnow spawnopen -afor the GUI editors; the effective argv changed (more robust).open_at,preview_command_at, andTargetare additive.Checks
just full-check(fmt + clippy) clean;cargo testgreen (28 unit + 10 doc) on default and--features specta.