# Maintain focus correctly when activating panes in zed2 \(\#3582\) · gitcafe/zed

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

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

Visibility: public

Requested revision: fdc0ef8ce021b7a281344016a45b818977c0dc17

Requested commit: fdc0ef8ce021b7a281344016a45b818977c0dc17

Commit: fdc0ef8ce021b7a281344016a45b818977c0dc17

Tree: 6657ad3afc11d8aef724c7d77230493c07b4dd40

Author: Antonio Scandurra

Committer: GitHub

## Message

```
Maintain focus correctly when activating panes in zed2 (#3582)

Previously, before emitting a `Focus` event from the pane inside of the
`focus_in` listener, we would erroneously check whether the pane's focus
handle was _not_ focused. However, by the time the pane was notified of
being "focused in", the focus handle would already be focused, which was
preventing the pane from ever emitting a `Focus` event. In turn, this
would cause the workspace to not maintain the active pane correctly.

This pull request maintains an explicit `was_focused` boolean as part of
the `Pane` state, which ensures we only emit the `Focus` event the first
time the pane receives focus.

As part of this, I also reworked how the outline view gets deployed to
allow clicking breadcrumbs even when the corresponding pane doesn't have
focus.

Release Notes:

- N/A
```

## Parents

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

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

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