Skip to content

Add Go to Entry right-click action in search results - #1100

Merged
sabrogden merged 2 commits into
sabrogden:masterfrom
izzy20044:feature/go-to-entry
May 6, 2026
Merged

sabrogden merged 2 commits into
sabrogden:masterfrom
izzy20044:feature/go-to-entry

Conversation

@izzy20044

@izzy20044 izzy20044 commented May 6, 2026 •

Copy link
Copy Markdown
Contributor

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:

  1. Clears the active search/filter.
  2. Reloads the unfiltered list.
  3. Selects the same clip you right-clicked, scrolled into view at its real chronological position.

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

  • Menu item placed directly under Filter On Selected Clip in IDR_QUICK_PASTE.
  • New command ID_MENU_GOTOENTRY (33000) plus standard ON_COMMAND / ON_UPDATE_COMMAND_UI wiring in CQPasteWnd.
  • OnUpdateMenuGoToEntry greys the item when the search box is empty.
  • Row position is computed via a single SQL COUNT(*) query against Main, mirroring FillLists default ORDER BY (stickyClipOrder DESC, bIsGroup ASC, clipOrder DESC). This avoids loading every row into m_listItems, which matters on large databases — single-row indexed query, no perceptible delay at 25 GB.
  • Honors m_bShowAllClipsInMainList and GetShowGroupsInMainList() so the rank query matches what FillList will produce.
  • If the user is currently inside a group and the targets lParentID differs, switches back to History view first via theApp.EnterGroupID(-1).
  • The wait for the loader threads m_SearchingEvent pumps the message queue, since list-load completion is reported via PostMessage(NM_SET_LIST_COUNT). A plain blocking WaitForSingleObject would starve that handler and leave the list at count 0 when EnsureVisible/SetListPos ran.
  • Falls back to 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_GOTOENTRY definition + _APS_NEXT_COMMAND_VALUE bump.
  • src/QPasteWnd.h — handler declarations.
  • src/QPasteWnd.cpp — message map entries + OnMenuGoToEntry / OnUpdateMenuGoToEntry.

Test plan

  • Build clean (Release | x64, MSVC v143 toolset).
  • Manual: search for a clip, right-click result, Go to Entry → search clears, target clip selected and scrolled into view.
  • Manual on ~25 GB DB: no perceptible delay (single-row COUNT(*) query, not a full load).
  • Menu item correctly greyed when search box empty.
  • Reviewer to verify behavior with m_bShowAllClipsInMainList = false and grouped clips.

A built Ditto.exe is attached to the corresponding release on the fork (v3.24.262.0-goto-entry) for anyone who wants to try the behavior before merging.

izzy20044 and others added 2 commits May 5, 2026 17:37
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.
@sabrogden
sabrogden merged commit 4dded9f into sabrogden:master May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants