Repository navigation
fix(search): clear find highlights when closing find on a content tab - #950
eugenioenko merged 1 commit into
Conversation
Closing the find bar while an image or binary tab was active returned early because no text editor was active, so the shared editor kept the previous text tab's SearchQuery and SearchMatches. Switching back to that tab showed the highlights again although find was closed. ClearFindHighlights and clearSearchState now always clear the shared editor's search state. The retained find query is kept, so F3 still works. Closes #939
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
eugenioenko
left a comment
There was a problem hiding this comment.
@cristianchiriac Nice fix, thank you for the patch :)
Summary
Closing the find bar while an image or binary tab was active did nothing to the editor highlights:
ClearFindHighlights(andclearSearchStateunder it) returned early becauseIsEditorActive()is false on a content tab. The sharedEditorstill held the previous text tab'sSearchQueryandSearchMatches, so switching back to that tab showed the matches highlighted with find closed.Both functions now clear the shared editor's search state whatever tab is active.
g.Editoris always set, and on a content tab it still holds the last text tab's buffer, which is the one the highlights belong to. The retained find query (g.find.query) is untouched, so F3/Shift+F3 keep working as described in the issue.Closes #939
Evidence
TestClosingFindOnImageTabClearsTextHighlights(tests/e2e/image_viewer_test.go): searchesfooin a text file, switches to a PNG tab, presses Escape, switches back and checks the editor has no search query or matches. Before the fix it fails withhighlights after closing find = "foo" [{0 0 3} {1 4 3}], want none; after the fix it passes.go test ./...passes andgolangci-lint runreports 0 issues (Go 1.25, Linux container);gofmt -l .is clean.--exectext screenshot can't show the difference; the e2e test checks the editor state directly.Notes
clearSearchStateis also used byClearSearch, so clearing a search while a content tab is active now clears the shared editor too, instead of leaving its highlights for later.Summary by CodeRabbit