Skip to content

Commit

Permalink
F3 now works with -search <search term> cmd-line arg (fixes #3806)
Browse files Browse the repository at this point in the history
  • Loading branch information
kjk committed Oct 26, 2023
1 parent 583655c commit 7fb7d28
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 7 deletions.
14 changes: 13 additions & 1 deletion docs/releasenotes.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,19 @@ the release notes, as we make them, to make the release process easier.

Next version:

3.5 (???)
3.6
* -search now copies search term to find box so that F3 works

3.5.2 (2023-10-25)
* fix not showing tab text
make menus in dark themes look more like standard menus (bigger padding)
* fix Bookmarks for folder showing bad file names

3.5.1 (2023-10-24)
* fix uninstaller crash
* disable lazy loading of files when restoring a session

3.5 (2023-10-23)
* CmdEditAnnotation select annotation under cursor and open annotation edit window
* rename CmdShowCursorPosition => CmdToggleCursorPosition
* add Annotations [ FreeTextColor, FreeTextSize, FreeTextBorderWidth ] settings
Expand Down
21 changes: 15 additions & 6 deletions src/SumatraStartup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,16 @@ static void FlagsEnterFullscreen(const Flags& flags, MainWindow* win) {
}
}

static void MaybeStartSearch(MainWindow* win, const char* searchTerm) {
if (!win || !searchTerm) {
return;
}
HwndSetText(win->hwndFindEdit, searchTerm);
bool wasModified = true;
bool showProgress = true;
FindTextOnThread(win, TextSearchDirection::Forward, searchTerm, wasModified, showProgress);
}

static MainWindow* LoadOnStartup(const char* filePath, const Flags& flags, bool isFirstWin) {
LoadArgs args(filePath, nullptr);
args.showWin = !(flags.printDialog && flags.exitWhenDone) && !gPluginMode;
Expand Down Expand Up @@ -317,11 +327,7 @@ static MainWindow* LoadOnStartup(const char* filePath, const Flags& flags, bool
int ret = win->AsFixed()->pdfSync->SourceToDoc(srcPath, flags.forwardSearchLine, 0, &page, rects);
ShowForwardSearchResult(win, srcPath, flags.forwardSearchLine, 0, ret, page, rects);
}
if (flags.search != nullptr) {
bool wasModified = true;
bool showProgress = true;
FindTextOnThread(win, TextSearchDirection::Forward, flags.search, wasModified, showProgress);
}
MaybeStartSearch(win, flags.search);
return win;
}

Expand Down Expand Up @@ -1306,7 +1312,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE, LPSTR, int) {
PrintCurrentFile(win, flags.exitWhenDone);
}
}
SelectTabInWindow(tabToSelect);
if (tabToSelect) {
SelectTabInWindow(tabToSelect);
MaybeStartSearch(tabToSelect->win, flags.search);
}

nWithDde = (int)gDdeOpenOnStartup.size();
if (nWithDde > 0) {
Expand Down

0 comments on commit 7fb7d28

Please sign in to comment.