Skip to content

Commit 4bcb283

Browse files
asklarDHowett
authored andcommitted
Remember last-used string in the Find dialog in conhost (#2845)
(cherry picked from commit bfb1484)
1 parent 93bc0af commit 4bcb283

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/interactivity/win32/find.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,16 @@ INT_PTR CALLBACK FindDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM l
2323
// This bool is used to track which option - up or down - was used to perform the last search. That way, the next time the
2424
// find dialog is opened, it will default to the last used option.
2525
static bool fFindSearchUp = true;
26+
static std::wstring lastFindString;
27+
2628
WCHAR szBuf[SEARCH_STRING_LENGTH + 1];
2729
switch (Message)
2830
{
2931
case WM_INITDIALOG:
3032
SetWindowLongPtrW(hWnd, DWLP_USER, lParam);
3133
SendDlgItemMessageW(hWnd, ID_CONSOLE_FINDSTR, EM_LIMITTEXT, ARRAYSIZE(szBuf) - 1, 0);
3234
CheckRadioButton(hWnd, ID_CONSOLE_FINDUP, ID_CONSOLE_FINDDOWN, (fFindSearchUp ? ID_CONSOLE_FINDUP : ID_CONSOLE_FINDDOWN));
35+
SetDlgItemText(hWnd, ID_CONSOLE_FINDSTR, lastFindString.c_str());
3336
return TRUE;
3437
case WM_COMMAND:
3538
{
@@ -40,6 +43,7 @@ INT_PTR CALLBACK FindDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM l
4043
USHORT const StringLength = (USHORT)GetDlgItemTextW(hWnd, ID_CONSOLE_FINDSTR, szBuf, ARRAYSIZE(szBuf));
4144
if (StringLength == 0)
4245
{
46+
lastFindString.clear();
4347
break;
4448
}
4549
bool const IgnoreCase = IsDlgButtonChecked(hWnd, ID_CONSOLE_FINDCASE) == 0;
@@ -48,7 +52,7 @@ INT_PTR CALLBACK FindDialogProc(HWND hWnd, UINT Message, WPARAM wParam, LPARAM l
4852
SCREEN_INFORMATION& ScreenInfo = gci.GetActiveOutputBuffer();
4953

5054
std::wstring wstr(szBuf, StringLength);
51-
55+
lastFindString = wstr;
5256
LockConsole();
5357
auto Unlock = wil::scope_exit([&] { UnlockConsole(); });
5458

0 commit comments

Comments
 (0)