# file_finder: Fix \`path:line\` navigation when target file is already open \(\#55875\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 9dc8880b2b96ae729539f9f6b971d0255a2f3b15

Requested commit: 9dc8880b2b96ae729539f9f6b971d0255a2f3b15

Commit: 9dc8880b2b96ae729539f9f6b971d0255a2f3b15

Tree: e2cffe4da70e2660312b48485549d178bb392641

Author: Kunall Banerjee

Committer: GitHub

## Message

```
file_finder: Fix `path:line` navigation when target file is already open (#55875)

Three pieces of state combined to break `path:line` queries when the
target file was already open:

- The `CreateNew` lookup ran against `query.raw_query.as_str()`, so a
path with a row suffix never matched the existing file and a stray
`Create file: foo.rs:3` row was always pushed.

- `calculate_selected_index` applied `skip_focus_for_active_in_search`
even when the query carried a row/column, jumping past the file the user
was asking to navigate inside.

- The preserved-selection path only invalidated on `path_query()`
changes. Appending `:3` to a typed-out path therefore kept the
previously skipped-to fuzzy neighbor selected, hiding the fix above when
the query was built up character by character.

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [ ] Unsafe blocks (if any) have justifying comments
- [ ] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [ ] Performance impact has been considered and is acceptable

Closes #55551

Release Notes:

- Fixed File Finder offering to create a file instead of navigating to a
line when the target file is already open
```

## Parents

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

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