@@ -5372,6 +5372,13 @@ void MultiReplace::handleReplaceInFiles() {
5372
5372
5373
5373
resetCountColumns ();
5374
5374
5375
+ std::vector<int > listFindTotals;
5376
+ std::vector<int > listReplaceTotals;
5377
+ if (useListEnabled) {
5378
+ listFindTotals.assign (replaceListData.size (), 0 );
5379
+ listReplaceTotals.assign (replaceListData.size (), 0 );
5380
+ }
5381
+
5375
5382
int total = static_cast <int >(files.size ()), idx = 0 , changed = 0 ;
5376
5383
showStatusMessage (L" Progress: [ 0%]" , MessageStatus::Info);
5377
5384
@@ -5425,43 +5432,45 @@ void MultiReplace::handleReplaceInFiles() {
5425
5432
send (SCI_ADDTEXT, utf8_input_buf.length (), reinterpret_cast <sptr_t >(utf8_input_buf.data ()));
5426
5433
5427
5434
handleDelimiterPositions (DelimiterOperation::LoadAll);
5428
- bool fileProcessedSuccessfully = handleReplaceAllButton (false , &fp);
5429
-
5430
- if (fileProcessedSuccessfully) {
5431
- // write the modified text back to the file.
5432
- std::string utf8_out = guard.getText ();
5433
-
5434
- // Restore original Scintilla context before writing
5435
- _hScintilla = oldSci;
5436
- pSciMsg = oldFn;
5437
- pSciWndData = oldData;
5438
-
5439
- if (utf8_out != utf8_input_buf) {
5440
- std::string final_write_buf;
5441
- if (convertUtf8ToOriginal (utf8_out, enc_info, original_buf, final_write_buf)) {
5442
- if (guard.writeFile (fp, final_write_buf)) {
5443
- ++changed; // Only increment if the file was successfully written.
5444
- }
5445
- }
5435
+
5436
+ if (!handleReplaceAllButton (false , &fp)) { _isCancelRequested = true ; break ; }
5437
+
5438
+ if (useListEnabled) {
5439
+ for (size_t i = 0 ; i < replaceListData.size (); ++i) {
5440
+ int f = replaceListData[i].findCount .empty ()
5441
+ ? 0 : std::stoi (replaceListData[i].findCount );
5442
+ int r = replaceListData[i].replaceCount .empty ()
5443
+ ? 0 : std::stoi (replaceListData[i].replaceCount );
5444
+ listFindTotals[i] += f;
5445
+ listReplaceTotals[i] += r;
5446
5446
}
5447
5447
}
5448
- else {
5449
- // The user clicked "Stop" (e.g., from the Debug Window).
5450
- // The changes for THIS file will be discarded as it's never written to disk.
5451
- _isCancelRequested = true ;
5452
- break ;
5453
- }
5454
5448
5449
+ std::string utf8_out = guard.getText ();
5450
+ _hScintilla = oldSci; pSciMsg = oldFn; pSciWndData = oldData;
5451
+
5452
+ if (utf8_out != utf8_input_buf) {
5453
+ std::string final_write_buf;
5454
+ if (convertUtf8ToOriginal (utf8_out, enc_info, original_buf, final_write_buf))
5455
+ if (guard.writeFile (fp, final_write_buf)) ++changed;
5456
+ }
5455
5457
}
5456
5458
5457
- // The UiStateGuard destructor automatically restores the UI here.
5459
+ if (useListEnabled) {
5460
+ for (size_t i = 0 ; i < replaceListData.size (); ++i) {
5461
+ replaceListData[i].findCount = std::to_wstring (listFindTotals[i]);
5462
+ replaceListData[i].replaceCount = std::to_wstring (listReplaceTotals[i]);
5463
+ updateCountColumns (i, listFindTotals[i], listReplaceTotals[i]);
5464
+ }
5465
+ refreshUIListView ();
5466
+ }
5458
5467
5459
- // Display a simple, universal summary message unless the plugin is shutting down.
5460
5468
if (!_isShuttingDown) {
5461
- std::wstring summaryMsg = LM.get (L" status_replace_summary" , { std::to_wstring (changed), std::to_wstring (total) });
5462
- showStatusMessage (summaryMsg, _isCancelRequested ? MessageStatus::Info : MessageStatus::Success);
5469
+ std::wstring summaryMsg = LM.get (L" status_replace_summary" ,
5470
+ { std::to_wstring (changed), std::to_wstring (files.size ()) });
5471
+ showStatusMessage (summaryMsg, _isCancelRequested ? MessageStatus::Info
5472
+ : MessageStatus::Success);
5463
5473
}
5464
-
5465
5474
_isCancelRequested = false ;
5466
5475
}
5467
5476
0 commit comments