Skip to content

Commit ae323dd

Browse files
committed
fixed rcFloat
1 parent d0f3981 commit ae323dd

File tree

2 files changed

+77
-106
lines changed

2 files changed

+77
-106
lines changed

src/MultiReplacePanel.cpp

Lines changed: 20 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6026,7 +6026,6 @@ void MultiReplace::CloseDebugWindow() {
60266026

60276027
#pragma region Find All
60286028

6029-
// Escape CR and LF in the search pattern for single-line header display
60306029
std::wstring MultiReplace::sanitizeSearchPattern(const std::wstring& raw) {
60316030
// Only escape CR and LF sequences, leave other characters unchanged
60326031
std::string utf8 = Encoding::wstringToUtf8(raw);
@@ -6035,7 +6034,6 @@ std::wstring MultiReplace::sanitizeSearchPattern(const std::wstring& raw) {
60356034
}
60366035

60376036

6038-
/// Helper to trim a Hit to its first visual document line, preserving highlight offsets
60396037
void MultiReplace::trimHitToFirstLine(
60406038
const std::function<LRESULT(UINT, WPARAM, LPARAM)>& sciSend,
60416039
ResultDock::Hit& h)
@@ -6083,45 +6081,43 @@ void MultiReplace::trimHitToFirstLine(
60836081

60846082
void MultiReplace::handleFindAllButton()
60856083
{
6086-
/* 1) sanity ------------------------------------------------------ */
6084+
// 1) sanity
60876085
if (!validateDelimiterData())
60886086
return;
60896087

6090-
/* 2) result dock ------------------------------------------------- */
6088+
// 2) result dock
60916089
ResultDock& dock = ResultDock::instance();
60926090
dock.ensureCreatedAndVisible(nppData);
60936091

6094-
/* 3) helper lambdas --------------------------------------------- */
6092+
// 3) helper lambdas
60956093
auto sciSend = [this](UINT m, WPARAM w = 0, LPARAM l = 0) -> LRESULT
60966094
{ return ::SendMessage(_hScintilla, m, w, l); };
60976095

6098-
/* 4) current file path ------------------------------------------ */
6096+
// 4) current file path
60996097
wchar_t buf[MAX_PATH] = {};
61006098
::SendMessage(nppData._nppHandle, NPPM_GETFULLCURRENTPATH, MAX_PATH, (LPARAM)buf);
61016099
std::wstring wFilePath = *buf ? buf : L"<untitled>";
61026100
std::string utf8FilePath = Encoding::wstringToUtf8(wFilePath);
61036101

6104-
/* 5) search context --------------------------------------------- */
6102+
// 5) search context
61056103
SearchContext context;
61066104
context.docLength = sciSend(SCI_GETLENGTH);
61076105
context.isColumnMode = (IsDlgButtonChecked(_hSelf, IDC_COLUMN_MODE_RADIO) == BST_CHECKED);
61086106
context.isSelectionMode = (IsDlgButtonChecked(_hSelf, IDC_SELECTION_RADIO) == BST_CHECKED);
61096107
context.retrieveFoundText = false;
61106108
context.highlightMatch = false;
61116109

6112-
/* starting position for selection‑mode scans -------------------- */
6110+
// starting position for selection‑mode scans
61136111
SelectionInfo selInfo = getSelectionInfo(false);
61146112
Sci_Position scanStart = context.isSelectionMode ? selInfo.startPos : 0;
61156113

6116-
/* 6) containers -------------------------------------------------- */
6114+
// 6) containers
61176115
ResultDock::FileMap fileMap;
61186116

61196117
std::vector<ResultDock::Hit> allHits;
61206118
int totalHits = 0;
61216119

6122-
/* ----------------------------------------------------------------
6123-
* LIST MODE (aggregate per‑file, then per‑criterion)
6124-
* ---------------------------------------------------------------- */
6120+
// LIST MODE (aggregate per‑file, then per‑criterion)
61256121
if (useListEnabled)
61266122
{
61276123
if (replaceListData.empty()) {
@@ -6133,18 +6129,18 @@ void MultiReplace::handleFindAllButton()
61336129
{
61346130
if (!item.isEnabled || item.findText.empty()) continue;
61356131

6136-
// +++ ADDED: Sanitize pattern for this criterion's header +++
6132+
// Sanitize pattern for this criterion's header +++
61376133
std::wstring sanitizedPattern = this->sanitizeSearchPattern(item.findText);
61386134

6139-
/* (a) Set up search flags & pattern ------------------- */
6135+
// (a) Set up search flags & pattern
61406136
context.findText = convertAndExtendW(item.findText, item.extended);
61416137
context.searchFlags =
61426138
(item.wholeWord ? SCFIND_WHOLEWORD : 0)
61436139
| (item.matchCase ? SCFIND_MATCHCASE : 0)
61446140
| (item.regex ? SCFIND_REGEXP : 0);
61456141
sciSend(SCI_SETSEARCHFLAGS, context.searchFlags);
61466142

6147-
/* (b) Collect hits ------------------------------------ */
6143+
// (b) Collect hits
61486144
std::vector<ResultDock::Hit> rawHits;
61496145
LRESULT pos = scanStart;
61506146
while (true)
@@ -6158,18 +6154,18 @@ void MultiReplace::handleFindAllButton()
61586154
h.pos = (Sci_Position)r.pos;
61596155
h.length = (Sci_Position)r.length;
61606156

6161-
// +++ ADDED: Trim hit to first line for display +++
6157+
// Trim hit to first line for display +++
61626158
this->trimHitToFirstLine(sciSend, h);
61636159
if (h.length > 0)
61646160
rawHits.push_back(std::move(h));
61656161
}
61666162
if (rawHits.empty()) continue;
61676163

6168-
/* (c) Aggregate per‑file ------------------------------ */
6164+
// (c) Aggregate per‑file
61696165
auto& agg = fileMap[utf8FilePath];
61706166
agg.wPath = wFilePath;
61716167
agg.hitCount += static_cast<int>(rawHits.size());
6172-
// +++ CHANGED: Use sanitized pattern for the criteria text +++
6168+
61736169
agg.crits.push_back({ sanitizedPattern, std::move(rawHits) });
61746170
totalHits += (int)agg.crits.back().hits.size();
61756171
}
@@ -6179,7 +6175,7 @@ void MultiReplace::handleFindAllButton()
61796175
return;
61806176
}
61816177

6182-
/* (d) Build dock text ------------------------------------ */
6178+
// (d) Build dock text
61836179
std::wstring header =
61846180
flatListEnabled
61856181
? L"Search in List – flat (" + std::to_wstring(totalHits) + L" hits in 1 file)\r\n"
@@ -6197,9 +6193,7 @@ void MultiReplace::handleFindAllButton()
61976193

61986194
dock.prependHits(allHits, dockText);
61996195
}
6200-
/* ----------------------------------------------------------------
6201-
* SINGLE MODE
6202-
* ---------------------------------------------------------------- */
6196+
// SINGLE MODE
62036197
else
62046198
{
62056199
std::wstring findW = getTextFromDialogItem(_hSelf, IDC_FIND_EDIT);
@@ -6209,7 +6203,7 @@ void MultiReplace::handleFindAllButton()
62096203
}
62106204
addStringToComboBoxHistory(GetDlgItem(_hSelf, IDC_FIND_EDIT), findW);
62116205

6212-
// +++ ADDED: Sanitize pattern for the header +++
6206+
// Sanitize pattern for the header
62136207
std::wstring headerPattern = this->sanitizeSearchPattern(findW);
62146208

62156209
context.findText = convertAndExtendW(findW,
@@ -6220,7 +6214,7 @@ void MultiReplace::handleFindAllButton()
62206214
| (IsDlgButtonChecked(_hSelf, IDC_REGEX_RADIO) == BST_CHECKED ? SCFIND_REGEXP : 0);
62216215
sciSend(SCI_SETSEARCHFLAGS, context.searchFlags);
62226216

6223-
/* collect hits ----------------------------------------- */
6217+
// collect hits
62246218
std::vector<ResultDock::Hit> rawHits;
62256219
LRESULT pos = context.isSelectionMode ? selInfo.startPos : 0;
62266220
while (true)
@@ -6234,7 +6228,7 @@ void MultiReplace::handleFindAllButton()
62346228
h.pos = r.pos;
62356229
h.length = r.length;
62366230

6237-
// +++ ADDED: Trim hit to first line for display +++
6231+
// Trim hit to first line for display
62386232
this->trimHitToFirstLine(sciSend, h);
62396233
if (h.length > 0)
62406234
rawHits.push_back(std::move(h));
@@ -6244,8 +6238,7 @@ void MultiReplace::handleFindAllButton()
62446238
return;
62456239
}
62466240

6247-
/* header ---------------------------------------------------- */
6248-
// +++ CHANGED: Use sanitized pattern for the header +++
6241+
// header
62496242
std::wstring header = L"Search \"" + headerPattern + L"\" (" + std::to_wstring(rawHits.size()) + L" hits in 1 file)\r\n";
62506243
size_t utf8Len = Encoding::wstringToUtf8(header).size();
62516244

0 commit comments

Comments
 (0)