+ chg: Open FInd/Replace: use most recent find pattern instead of clipboard (if selection is empty)

This commit is contained in:
Rainer Kottenhoff 2018-12-05 08:04:08 +01:00
parent eb8c6c8ddf
commit 057165ec14
2 changed files with 17 additions and 10 deletions

View File

@ -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);
}
}

View File

@ -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;