From 057165ec148b71f60375add7bfe676f49417ddbc Mon Sep 17 00:00:00 2001 From: Rainer Kottenhoff Date: Wed, 5 Dec 2018 08:04:08 +0100 Subject: [PATCH] + chg: Open FInd/Replace: use most recent find pattern instead of clipboard (if selection is empty) --- src/Edit.c | 25 ++++++++++++++++--------- src/TypeDefs.h | 2 +- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/src/Edit.c b/src/Edit.c index f1b8bfe35..629ebdf34 100644 --- a/src/Edit.c +++ b/src/Edit.c @@ -5261,16 +5261,23 @@ INT_PTR CALLBACK EditFindReplaceDlgProcW(HWND hwnd,UINT umsg,WPARAM wParam,LPARA } else if (cchSelection <= 1) { // nothing is selected in the editor: - // if first time you bring up find/replace dialog, - // copy content clipboard to find box - char* pClip = EditGetClipboardText(hwnd, false, NULL, NULL); - if (pClip) { - size_t const len = StringCchLenA(pClip,0); - if (len) { - lpszSelection = AllocMem(len + 1, HEAP_ZERO_MEMORY); - StringCchCopyNA(lpszSelection, len + 1, pClip, len); + // if first time you bring up find/replace dialog, + // use most recent search pattern to find box + GetFindPattern(tchBuf, FNDRPL_BUFFER); + if (tchBuf[0] == L'\0') { + MRU_Enum(Globals.pMRUfind, 0, tchBuf, COUNTOF(tchBuf)); + } + // no recent find pattern: copy content clipboard to find box + if (tchBuf[0] == L'\0') { + char* pClip = EditGetClipboardText(hwnd, false, NULL, NULL); + if (pClip) { + size_t const len = StringCchLenA(pClip, 0); + if (len) { + lpszSelection = AllocMem(len + 1, HEAP_ZERO_MEMORY); + StringCchCopyNA(lpszSelection, len + 1, pClip, len); + } + FreeMem(pClip); } - FreeMem(pClip); } } diff --git a/src/TypeDefs.h b/src/TypeDefs.h index 0deb5a25d..beee2555c 100644 --- a/src/TypeDefs.h +++ b/src/TypeDefs.h @@ -95,7 +95,7 @@ typedef enum XXXL_BUFFER = 4096, ANSI_CHAR_BUFFER = 258, - FNDRPL_BUFFER = 1024, + FNDRPL_BUFFER = 2048, LONG_LINES_MARKER_LIMIT = 4096 } BUFFER_SIZES;