workspace: Fix cross-host window reuse - #62561
Open
hamishc wants to merge 1 commit into
Open
Conversation
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.
Objective
Opening a remote folder on one host can silently activate an already-open window connected to a different host that has an identically-named path, instead of connecting.
Repro:
/foo/baron ssh host A, then open a project on host B in the same window (host A's workspace stays retained in the background)./foo/baron host B.Cause:
find_existing_workspacefilters candidate windows by host, but then path-scores every workspace held in a qualifying window without checking each workspace's own location, so a request for host B can match host A's workspace by path alone. The window fallbacks inopen_pathsand the--waitbranch had the same flaw - they used the window's displayed workspace unchecked, so zed could resolve a local path on a remote host.Solution
Testing
test_find_existing_workspace_requires_matching_location) covering the scoring loop and the--waitfallback in a mixed-location window; verified it fails without the fix.cargo test -p workspace -p recent_projects,cargo check -p zed, and./script/clippyall pass.Self-Review Checklist:
Release Notes: