# git_ui: Resolve worktree picker remove-from-window clicks by path \(\#59084\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/af7bdd5fef6acab34704cfb09143221031588565)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: af7bdd5fef6acab34704cfb09143221031588565

Requested commit: af7bdd5fef6acab34704cfb09143221031588565

Commit: af7bdd5fef6acab34704cfb09143221031588565

Tree: dc0be57920e4bd364fa6820f107a58a0fcfa1c82

Author: MartinYe1234

Committer: GitHub

## Message

```
git_ui: Resolve worktree picker remove-from-window clicks by path (#59084)

Follow-up to #58996. The "Remove Worktree from Window" button captured
the row index at render time and re-resolved it against the picker's
matches at click time. Matches are rebuilt asynchronously (initial
worktree list load, post-delete refresh, query changes), so the index
could drift between the rendered frame and the click being processed,
closing the workspace of a different worktree than the one the user
clicked.

This changes the click handler to capture the worktree's path — a stable
identity — instead of its index, adds the same `deleting_worktree_paths`
click-time guard the neighboring handlers use, and constructs the button
only when it will actually be shown.

Scoped to the code added in #58996; the same stale-index pattern in the
delete and open-in-new-window handlers is left for a later change.

Release Notes:

- Fixed an issue where the worktree picker's "Remove Worktree from
Window" button could act on the wrong worktree if the list updated at
the moment of the click.
```

## Parents

- [ce22d1ab28b6b7545290de33d427d63c363d7f16](https://git.cafe/gitcafe/zed/commit/ce22d1ab28b6b7545290de33d427d63c363d7f16?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/af7bdd5fef6acab34704cfb09143221031588565?format=markdown)
