# editor: Fix navigate back for locations opened via preview item \(\#26943\) · gitcafe/zed

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

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

Visibility: public

Requested revision: cb439e672da47dcebfd3df2fac15da846152ac47

Requested commit: cb439e672da47dcebfd3df2fac15da846152ac47

Commit: cb439e672da47dcebfd3df2fac15da846152ac47

Tree: 8fda8862d89cf42ce9b58063a02fb120236b3d19

Author: Smit Barmase

Committer: GitHub

## Message

```
editor: Fix navigate back for locations opened via preview item (#26943)

Closes #25458

When navigating code from a preview tab with
`enable_preview_from_code_navigation` set to `true`, "Go Back" from a
newly opened tab could focus on the tab to the right instead of
returning to the original preview tab.

Before, we killed the existing preview tab before opening a new one,
which breaking history as the new tab had no reference to the old one.
This caused navigation to shift to the next tab on the right.

Now, we first add the new tab at the preview index, and then kill the
existing preview tab. This preserves the history by linking new preview
tab to existing tab.

Release Notes:

- Fixes an issue where navigating code from a preview tab with
`enable_preview_from_code_navigation` set to `true`, "Go Back" from a
newly opened tab could focus on the tab to the right instead of
returning to the original preview tab.
```

## Parents

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

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