Skip to content

Commit d384816

Browse files
committed
enhanced Column and Selection Mode
1 parent 50202cc commit d384816

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

src/MultiReplacePanel.cpp

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6047,14 +6047,22 @@ void MultiReplace::handleFindAllButton()
60476047
std::string utf8FilePath = Encoding::wstringToUtf8(wFilePath);
60486048

60496049
/* 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;
60516060

60526061
/* 6) containers -------------------------------------------------- */
60536062
ResultDock::FileMap fileMap;
60546063

60556064
std::vector<ResultDock::Hit> allHits;
60566065
int totalHits = 0;
6057-
size_t utf8Len = 0; // <‑‑ running UTF‑8 length for styling (visible everywhere)
60586066

60596067
/* ----------------------------------------------------------------
60606068
* LIST MODE (aggregate per‑file, then per‑criterion)
@@ -6071,19 +6079,19 @@ void MultiReplace::handleFindAllButton()
60716079
if (!item.isEnabled || item.findText.empty()) continue;
60726080

60736081
/* (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 =
60766084
(item.wholeWord ? SCFIND_WHOLEWORD : 0)
60776085
| (item.matchCase ? SCFIND_MATCHCASE : 0)
60786086
| (item.regex ? SCFIND_REGEXP : 0);
6079-
sciSend(SCI_SETSEARCHFLAGS, ctx.searchFlags);
6087+
sciSend(SCI_SETSEARCHFLAGS, context.searchFlags);
60806088

60816089
/* (b) Collect hits ------------------------------------ */
60826090
std::vector<ResultDock::Hit> rawHits;
6083-
LRESULT pos = 0;
6091+
LRESULT pos = scanStart;
60846092
while (true)
60856093
{
6086-
SearchResult r = performSearchForward(ctx, pos);
6094+
SearchResult r = performSearchForward(context, pos);
60876095
if (r.pos < 0) break;
60886096
pos = r.pos + r.length;
60896097

@@ -6127,7 +6135,7 @@ void MultiReplace::handleFindAllButton()
61276135
dock.prependHits(allHits, dockText);
61286136
}
61296137
/* ----------------------------------------------------------------
6130-
* SINGLE MODE (original implementation – only utf8Len adjusted)
6138+
* SINGLE MODE
61316139
* ---------------------------------------------------------------- */
61326140
else
61336141
{
@@ -6138,20 +6146,20 @@ void MultiReplace::handleFindAllButton()
61386146
}
61396147
addStringToComboBoxHistory(GetDlgItem(_hSelf, IDC_FIND_EDIT), findW);
61406148

6141-
ctx.findText = convertAndExtendW(findW,
6149+
context.findText = convertAndExtendW(findW,
61426150
IsDlgButtonChecked(_hSelf, IDC_EXTENDED_RADIO) == BST_CHECKED);
6143-
ctx.searchFlags =
6151+
context.searchFlags =
61446152
(IsDlgButtonChecked(_hSelf, IDC_WHOLE_WORD_CHECKBOX) == BST_CHECKED ? SCFIND_WHOLEWORD : 0)
61456153
| (IsDlgButtonChecked(_hSelf, IDC_MATCH_CASE_CHECKBOX) == BST_CHECKED ? SCFIND_MATCHCASE : 0)
61466154
| (IsDlgButtonChecked(_hSelf, IDC_REGEX_RADIO) == BST_CHECKED ? SCFIND_REGEXP : 0);
6147-
sciSend(SCI_SETSEARCHFLAGS, ctx.searchFlags);
6155+
sciSend(SCI_SETSEARCHFLAGS, context.searchFlags);
61486156

61496157
/* collect hits ----------------------------------------- */
61506158
std::vector<ResultDock::Hit> rawHits;
6151-
LRESULT pos = 0;
6159+
LRESULT pos = context.isSelectionMode ? selInfo.startPos : 0;
61526160
while (true)
61536161
{
6154-
SearchResult r = performSearchForward(ctx, pos);
6162+
SearchResult r = performSearchForward(context, pos);
61556163
if (r.pos < 0) break;
61566164
pos = r.pos + r.length;
61576165

@@ -6168,7 +6176,7 @@ void MultiReplace::handleFindAllButton()
61686176

61696177
/* header ---------------------------------------------------- */
61706178
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();
61726180

61736181
std::wstring block;
61746182
dock.formatHitsForFile(wFilePath, sciSend, rawHits, block, utf8Len);

0 commit comments

Comments
 (0)