Do not jump to search match when sourcing search string from selected text in document.#722
Open
abebinder wants to merge 1 commit intolinuxmint:masterfrom
Open
Do not jump to search match when sourcing search string from selected text in document.#722abebinder wants to merge 1 commit intolinuxmint:masterfrom
abebinder wants to merge 1 commit intolinuxmint:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related Issue
#402
TLDR
An async callback runs whenever the searchbar text is changed which changes the selection to the first match in the document
xed/xed/xed-searchbar.c
Lines 140 to 141 in 78ff0d1
I tried to stop the callback from running for case where we select text in the document then do a search.
Before
2026-02-16.21-10-49.mp4
After
2026-02-16.21-26-59.mp4
Explanation Of Problem
When you select text in the document and then do a search using
Search -> Findmenu button (or ctrl + f), the search bar is opened and the selected text is copied into the search bar. All this rocks and is great and is like other editors.Ideally, after that happens, the text in the searchbar would now be selected. This is what happens for other editors (eg: sublime). It also is consistent with xeds behavior when you do a
Search->Findwithout any text in the document selected (in that case, it will open the search bar and select whatever was in the search bar previously).However, when you do have text in the document selected, this does not happen for xed. This is because the following call chain happens:
search_text_entry_changed -> do_find -> run_forward_search -> forward_search_finishedIn
forward_search_finished, we change the selection of the text to one of the "matches" for that search in the document:xed/xed/xed-searchbar.c
Lines 140 to 141 in 78ff0d1
This "forward search" which changes the selection to the matches in the document is good behavior when we are typing in the search bar but not really after initializing the search bar with selected text from the document.
Explanation of Fix
Add logic that makes it so we don't call the "run_forward_search" function if we are initializing the search bar with selected text from the document.
Alternative Solution
One thing I noticed when using sublime is that the text selection never changes at all when using find and the next/previous buttons. It always stays selected in the search bar. They just highlight the matches instead of selecting them. That makes lots of sense to me but is more involved change. Would be willing to try that though if asked.
Screenshot from sublime: