@@ -6026,7 +6026,6 @@ void MultiReplace::CloseDebugWindow() {
6026
6026
6027
6027
#pragma region Find All
6028
6028
6029
- // Escape CR and LF in the search pattern for single-line header display
6030
6029
std::wstring MultiReplace::sanitizeSearchPattern (const std::wstring& raw) {
6031
6030
// Only escape CR and LF sequences, leave other characters unchanged
6032
6031
std::string utf8 = Encoding::wstringToUtf8 (raw);
@@ -6035,7 +6034,6 @@ std::wstring MultiReplace::sanitizeSearchPattern(const std::wstring& raw) {
6035
6034
}
6036
6035
6037
6036
6038
- // / Helper to trim a Hit to its first visual document line, preserving highlight offsets
6039
6037
void MultiReplace::trimHitToFirstLine (
6040
6038
const std::function<LRESULT(UINT, WPARAM, LPARAM)>& sciSend,
6041
6039
ResultDock::Hit& h)
@@ -6083,45 +6081,43 @@ void MultiReplace::trimHitToFirstLine(
6083
6081
6084
6082
void MultiReplace::handleFindAllButton ()
6085
6083
{
6086
- /* 1) sanity ------------------------------------------------------ */
6084
+ // 1) sanity
6087
6085
if (!validateDelimiterData ())
6088
6086
return ;
6089
6087
6090
- /* 2) result dock ------------------------------------------------- */
6088
+ // 2) result dock
6091
6089
ResultDock& dock = ResultDock::instance ();
6092
6090
dock.ensureCreatedAndVisible (nppData);
6093
6091
6094
- /* 3) helper lambdas --------------------------------------------- */
6092
+ // 3) helper lambdas
6095
6093
auto sciSend = [this ](UINT m, WPARAM w = 0 , LPARAM l = 0 ) -> LRESULT
6096
6094
{ return ::SendMessage (_hScintilla, m, w, l); };
6097
6095
6098
- /* 4) current file path ------------------------------------------ */
6096
+ // 4) current file path
6099
6097
wchar_t buf[MAX_PATH] = {};
6100
6098
::SendMessage (nppData._nppHandle, NPPM_GETFULLCURRENTPATH, MAX_PATH, (LPARAM)buf);
6101
6099
std::wstring wFilePath = *buf ? buf : L" <untitled>" ;
6102
6100
std::string utf8FilePath = Encoding::wstringToUtf8 (wFilePath);
6103
6101
6104
- /* 5) search context --------------------------------------------- */
6102
+ // 5) search context
6105
6103
SearchContext context;
6106
6104
context.docLength = sciSend (SCI_GETLENGTH);
6107
6105
context.isColumnMode = (IsDlgButtonChecked (_hSelf, IDC_COLUMN_MODE_RADIO) == BST_CHECKED);
6108
6106
context.isSelectionMode = (IsDlgButtonChecked (_hSelf, IDC_SELECTION_RADIO) == BST_CHECKED);
6109
6107
context.retrieveFoundText = false ;
6110
6108
context.highlightMatch = false ;
6111
6109
6112
- /* starting position for selection‑mode scans -------------------- */
6110
+ // starting position for selection‑mode scans
6113
6111
SelectionInfo selInfo = getSelectionInfo (false );
6114
6112
Sci_Position scanStart = context.isSelectionMode ? selInfo.startPos : 0 ;
6115
6113
6116
- /* 6) containers -------------------------------------------------- */
6114
+ // 6) containers
6117
6115
ResultDock::FileMap fileMap;
6118
6116
6119
6117
std::vector<ResultDock::Hit> allHits;
6120
6118
int totalHits = 0 ;
6121
6119
6122
- /* ----------------------------------------------------------------
6123
- * LIST MODE (aggregate per‑file, then per‑criterion)
6124
- * ---------------------------------------------------------------- */
6120
+ // LIST MODE (aggregate per‑file, then per‑criterion)
6125
6121
if (useListEnabled)
6126
6122
{
6127
6123
if (replaceListData.empty ()) {
@@ -6133,18 +6129,18 @@ void MultiReplace::handleFindAllButton()
6133
6129
{
6134
6130
if (!item.isEnabled || item.findText .empty ()) continue ;
6135
6131
6136
- // +++ ADDED: Sanitize pattern for this criterion's header +++
6132
+ // Sanitize pattern for this criterion's header +++
6137
6133
std::wstring sanitizedPattern = this ->sanitizeSearchPattern (item.findText );
6138
6134
6139
- /* (a) Set up search flags & pattern ------------------- */
6135
+ // (a) Set up search flags & pattern
6140
6136
context.findText = convertAndExtendW (item.findText , item.extended );
6141
6137
context.searchFlags =
6142
6138
(item.wholeWord ? SCFIND_WHOLEWORD : 0 )
6143
6139
| (item.matchCase ? SCFIND_MATCHCASE : 0 )
6144
6140
| (item.regex ? SCFIND_REGEXP : 0 );
6145
6141
sciSend (SCI_SETSEARCHFLAGS, context.searchFlags );
6146
6142
6147
- /* (b) Collect hits ------------------------------------ */
6143
+ // (b) Collect hits
6148
6144
std::vector<ResultDock::Hit> rawHits;
6149
6145
LRESULT pos = scanStart;
6150
6146
while (true )
@@ -6158,18 +6154,18 @@ void MultiReplace::handleFindAllButton()
6158
6154
h.pos = (Sci_Position)r.pos ;
6159
6155
h.length = (Sci_Position)r.length ;
6160
6156
6161
- // +++ ADDED: Trim hit to first line for display +++
6157
+ // Trim hit to first line for display +++
6162
6158
this ->trimHitToFirstLine (sciSend, h);
6163
6159
if (h.length > 0 )
6164
6160
rawHits.push_back (std::move (h));
6165
6161
}
6166
6162
if (rawHits.empty ()) continue ;
6167
6163
6168
- /* (c) Aggregate per‑file ------------------------------ */
6164
+ // (c) Aggregate per‑file
6169
6165
auto & agg = fileMap[utf8FilePath];
6170
6166
agg.wPath = wFilePath;
6171
6167
agg.hitCount += static_cast <int >(rawHits.size ());
6172
- // +++ CHANGED: Use sanitized pattern for the criteria text +++
6168
+
6173
6169
agg.crits .push_back ({ sanitizedPattern, std::move (rawHits) });
6174
6170
totalHits += (int )agg.crits .back ().hits .size ();
6175
6171
}
@@ -6179,7 +6175,7 @@ void MultiReplace::handleFindAllButton()
6179
6175
return ;
6180
6176
}
6181
6177
6182
- /* (d) Build dock text ------------------------------------ */
6178
+ // (d) Build dock text
6183
6179
std::wstring header =
6184
6180
flatListEnabled
6185
6181
? L" Search in List – flat (" + std::to_wstring (totalHits) + L" hits in 1 file)\r\n "
@@ -6197,9 +6193,7 @@ void MultiReplace::handleFindAllButton()
6197
6193
6198
6194
dock.prependHits (allHits, dockText);
6199
6195
}
6200
- /* ----------------------------------------------------------------
6201
- * SINGLE MODE
6202
- * ---------------------------------------------------------------- */
6196
+ // SINGLE MODE
6203
6197
else
6204
6198
{
6205
6199
std::wstring findW = getTextFromDialogItem (_hSelf, IDC_FIND_EDIT);
@@ -6209,7 +6203,7 @@ void MultiReplace::handleFindAllButton()
6209
6203
}
6210
6204
addStringToComboBoxHistory (GetDlgItem (_hSelf, IDC_FIND_EDIT), findW);
6211
6205
6212
- // +++ ADDED: Sanitize pattern for the header +++
6206
+ // Sanitize pattern for the header
6213
6207
std::wstring headerPattern = this ->sanitizeSearchPattern (findW);
6214
6208
6215
6209
context.findText = convertAndExtendW (findW,
@@ -6220,7 +6214,7 @@ void MultiReplace::handleFindAllButton()
6220
6214
| (IsDlgButtonChecked (_hSelf, IDC_REGEX_RADIO) == BST_CHECKED ? SCFIND_REGEXP : 0 );
6221
6215
sciSend (SCI_SETSEARCHFLAGS, context.searchFlags );
6222
6216
6223
- /* collect hits ----------------------------------------- */
6217
+ // collect hits
6224
6218
std::vector<ResultDock::Hit> rawHits;
6225
6219
LRESULT pos = context.isSelectionMode ? selInfo.startPos : 0 ;
6226
6220
while (true )
@@ -6234,7 +6228,7 @@ void MultiReplace::handleFindAllButton()
6234
6228
h.pos = r.pos ;
6235
6229
h.length = r.length ;
6236
6230
6237
- // +++ ADDED: Trim hit to first line for display +++
6231
+ // Trim hit to first line for display
6238
6232
this ->trimHitToFirstLine (sciSend, h);
6239
6233
if (h.length > 0 )
6240
6234
rawHits.push_back (std::move (h));
@@ -6244,8 +6238,7 @@ void MultiReplace::handleFindAllButton()
6244
6238
return ;
6245
6239
}
6246
6240
6247
- /* header ---------------------------------------------------- */
6248
- // +++ CHANGED: Use sanitized pattern for the header +++
6241
+ // header
6249
6242
std::wstring header = L" Search \" " + headerPattern + L" \" (" + std::to_wstring (rawHits.size ()) + L" hits in 1 file)\r\n " ;
6250
6243
size_t utf8Len = Encoding::wstringToUtf8 (header).size ();
6251
6244
0 commit comments