# Fix slow focus transitions to the terminal panel \(\#24172\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 69bb0a0597f74704604805a5ddff5df7207b0f3b

Requested commit: 69bb0a0597f74704604805a5ddff5df7207b0f3b

Commit: 69bb0a0597f74704604805a5ddff5df7207b0f3b

Tree: 7e6f39a67aa0f7d903bb0a01ea894f623b4f7851

Author: Mikayla Maki

Committer: GitHub

## Message

```
Fix slow focus transitions to the terminal panel (#24172)

This long standing bug was caused by `Pane`'s focus_in handler bouncing
the focus to another handle.
Because focus resolution happens _after_ a frame has been rendered, the
only way to deal with this case is to schedule another frame to be
redrawn. However, we where suppressing all window refreshes that occur
during a focus transfer, causing this focus change to be completely
missed. However, changing this behavior can lead to infinite notify
loops, due to drawing a frame causing another to be rendered.

This PR fixes this problem narrowly by adding an `on_next_frame()`
callback in the pane's focus handle, so that the focus changes take
effect almost immediately. But only for this case, where we know it
doesn't cause infinite notify loops.

TODO:
- [x] Fix the infinite notify loop bug or determine a third way to fix
this lag

Release Notes:

- Fixed a bug where shifting focus to the terminal panel could be slow
```

## Parents

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

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