Repository navigation
Add Go to Entry right-click action in search results - #1100
Merged
Merged
Conversation
When a search/filter is active, right-clicking a result now offers a "Go to Entry" command that clears the active filter and scrolls/selects the same clip in the unfiltered chronological list. The row position is computed via a single SQL COUNT(*) query against Main, mirroring FillList's default ORDER BY (stickyClipOrder DESC, bIsGroup ASC, clipOrder DESC). This avoids loading every row into memory, which matters on large databases (tested at ~25 GB). The handler also pumps the message queue while waiting for the loader thread's m_SearchingEvent, since list-load completion is reported via PostMessage(NM_SET_LIST_COUNT) which would otherwise be starved by a synchronous WaitForSingleObject. Menu item is enabled only while the search box is non-empty.
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.
What this does (user-facing)
Today, when you press Ctrl+F and type a search in Ditto, the list filters in place. If you find the clip you wanted, there is no quick way to see where it actually sits in your full chronological clip history — you have to look at the timestamp and scroll back to it manually. On a large clip log this is genuinely tedious.
This PR adds a Go to Entry item to the right-click menu on search results. Clicking it:
The menu item is greyed out when the search box is empty (nothing to "go back from").
That is the entire user-visible change.
Why
On large clip databases (this was developed against a ~25 GB DB) the manual "read the timestamp, scroll, hunt" routine after a search is painful. This makes the search a navigation tool, not just a filter.
Implementation notes
IDR_QUICK_PASTE.ID_MENU_GOTOENTRY(33000) plus standardON_COMMAND/ON_UPDATE_COMMAND_UIwiring inCQPasteWnd.OnUpdateMenuGoToEntrygreys the item when the search box is empty.COUNT(*)query againstMain, mirroringFillLists defaultORDER BY(stickyClipOrder DESC, bIsGroup ASC, clipOrder DESC). This avoids loading every row intom_listItems, which matters on large databases — single-row indexed query, no perceptible delay at 25 GB.m_bShowAllClipsInMainListandGetShowGroupsInMainList()so the rank query matches whatFillListwill produce.lParentIDdiffers, switches back to History view first viatheApp.EnterGroupID(-1).m_SearchingEventpumps the message queue, since list-load completion is reported viaPostMessage(NM_SET_LIST_COUNT). A plain blockingWaitForSingleObjectwould starve that handler and leave the list at count 0 whenEnsureVisible/SetListPosran.SelectFocusID()if the SQL rank ends up out of range (defensive — should not happen in practice).Files changed
CP_Main.rc— menu item.resource.h—ID_MENU_GOTOENTRYdefinition +_APS_NEXT_COMMAND_VALUEbump.src/QPasteWnd.h— handler declarations.src/QPasteWnd.cpp— message map entries +OnMenuGoToEntry/OnUpdateMenuGoToEntry.Test plan
m_bShowAllClipsInMainList = falseand grouped clips.A built
Ditto.exeis attached to the corresponding release on the fork (v3.24.262.0-goto-entry) for anyone who wants to try the behavior before merging.