@@ -6047,14 +6047,22 @@ void MultiReplace::handleFindAllButton()
6047
6047
std::string utf8FilePath = Encoding::wstringToUtf8 (wFilePath);
6048
6048
6049
6049
/* 5) search context --------------------------------------------- */
6050
- SearchContext ctx{}; ctx.docLength = sciSend (SCI_GETLENGTH);
6050
+ SearchContext context;
6051
+ context.docLength = sciSend (SCI_GETLENGTH);
6052
+ context.isColumnMode = (IsDlgButtonChecked (_hSelf, IDC_COLUMN_MODE_RADIO) == BST_CHECKED);
6053
+ context.isSelectionMode = (IsDlgButtonChecked (_hSelf, IDC_SELECTION_RADIO) == BST_CHECKED);
6054
+ context.retrieveFoundText = false ;
6055
+ context.highlightMatch = false ;
6056
+
6057
+ /* starting position for selection‑mode scans -------------------- */
6058
+ SelectionInfo selInfo = getSelectionInfo (false );
6059
+ Sci_Position scanStart = context.isSelectionMode ? selInfo.startPos : 0 ;
6051
6060
6052
6061
/* 6) containers -------------------------------------------------- */
6053
6062
ResultDock::FileMap fileMap;
6054
6063
6055
6064
std::vector<ResultDock::Hit> allHits;
6056
6065
int totalHits = 0 ;
6057
- size_t utf8Len = 0 ; // <‑‑ running UTF‑8 length for styling (visible everywhere)
6058
6066
6059
6067
/* ----------------------------------------------------------------
6060
6068
* LIST MODE (aggregate per‑file, then per‑criterion)
@@ -6071,19 +6079,19 @@ void MultiReplace::handleFindAllButton()
6071
6079
if (!item.isEnabled || item.findText .empty ()) continue ;
6072
6080
6073
6081
/* (a) Set up search flags & pattern ------------------- */
6074
- ctx .findText = convertAndExtendW (item.findText , item.extended );
6075
- ctx .searchFlags =
6082
+ context .findText = convertAndExtendW (item.findText , item.extended );
6083
+ context .searchFlags =
6076
6084
(item.wholeWord ? SCFIND_WHOLEWORD : 0 )
6077
6085
| (item.matchCase ? SCFIND_MATCHCASE : 0 )
6078
6086
| (item.regex ? SCFIND_REGEXP : 0 );
6079
- sciSend (SCI_SETSEARCHFLAGS, ctx .searchFlags );
6087
+ sciSend (SCI_SETSEARCHFLAGS, context .searchFlags );
6080
6088
6081
6089
/* (b) Collect hits ------------------------------------ */
6082
6090
std::vector<ResultDock::Hit> rawHits;
6083
- LRESULT pos = 0 ;
6091
+ LRESULT pos = scanStart ;
6084
6092
while (true )
6085
6093
{
6086
- SearchResult r = performSearchForward (ctx , pos);
6094
+ SearchResult r = performSearchForward (context , pos);
6087
6095
if (r.pos < 0 ) break ;
6088
6096
pos = r.pos + r.length ;
6089
6097
@@ -6127,7 +6135,7 @@ void MultiReplace::handleFindAllButton()
6127
6135
dock.prependHits (allHits, dockText);
6128
6136
}
6129
6137
/* ----------------------------------------------------------------
6130
- * SINGLE MODE (original implementation – only utf8Len adjusted)
6138
+ * SINGLE MODE
6131
6139
* ---------------------------------------------------------------- */
6132
6140
else
6133
6141
{
@@ -6138,20 +6146,20 @@ void MultiReplace::handleFindAllButton()
6138
6146
}
6139
6147
addStringToComboBoxHistory (GetDlgItem (_hSelf, IDC_FIND_EDIT), findW);
6140
6148
6141
- ctx .findText = convertAndExtendW (findW,
6149
+ context .findText = convertAndExtendW (findW,
6142
6150
IsDlgButtonChecked (_hSelf, IDC_EXTENDED_RADIO) == BST_CHECKED);
6143
- ctx .searchFlags =
6151
+ context .searchFlags =
6144
6152
(IsDlgButtonChecked (_hSelf, IDC_WHOLE_WORD_CHECKBOX) == BST_CHECKED ? SCFIND_WHOLEWORD : 0 )
6145
6153
| (IsDlgButtonChecked (_hSelf, IDC_MATCH_CASE_CHECKBOX) == BST_CHECKED ? SCFIND_MATCHCASE : 0 )
6146
6154
| (IsDlgButtonChecked (_hSelf, IDC_REGEX_RADIO) == BST_CHECKED ? SCFIND_REGEXP : 0 );
6147
- sciSend (SCI_SETSEARCHFLAGS, ctx .searchFlags );
6155
+ sciSend (SCI_SETSEARCHFLAGS, context .searchFlags );
6148
6156
6149
6157
/* collect hits ----------------------------------------- */
6150
6158
std::vector<ResultDock::Hit> rawHits;
6151
- LRESULT pos = 0 ;
6159
+ LRESULT pos = context. isSelectionMode ? selInfo. startPos : 0 ;
6152
6160
while (true )
6153
6161
{
6154
- SearchResult r = performSearchForward (ctx , pos);
6162
+ SearchResult r = performSearchForward (context , pos);
6155
6163
if (r.pos < 0 ) break ;
6156
6164
pos = r.pos + r.length ;
6157
6165
@@ -6168,7 +6176,7 @@ void MultiReplace::handleFindAllButton()
6168
6176
6169
6177
/* header ---------------------------------------------------- */
6170
6178
std::wstring header = L" Search \" " + findW + L" \" (" + std::to_wstring (rawHits.size ()) + L" hits in 1 file)\r\n " ;
6171
- utf8Len = Encoding::wstringToUtf8 (header).size ();
6179
+ size_t utf8Len = Encoding::wstringToUtf8 (header).size ();
6172
6180
6173
6181
std::wstring block;
6174
6182
dock.formatHitsForFile (wFilePath, sciSend, rawHits, block, utf8Len);
0 commit comments