diff --git a/src/lang/ar-ye.json b/src/lang/ar-ye.json index 4596167da..694fefc01 100644 --- a/src/lang/ar-ye.json +++ b/src/lang/ar-ye.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/az-az.json b/src/lang/az-az.json index 01fe0207c..76b48d21c 100644 --- a/src/lang/az-az.json +++ b/src/lang/az-az.json @@ -913,5 +913,6 @@ "error-no-space": "Bu cihazda kifayət qədər boş yaddaş sahəsi qalmayıb.", "error-network": "Serverlə əlaqə qurmaq mümkün olmadı. Əlaqəni yoxla və yenidən cəhd et.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/be-by.json b/src/lang/be-by.json index cf32ddf99..c6c8b21f2 100644 --- a/src/lang/be-by.json +++ b/src/lang/be-by.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/bn-bd.json b/src/lang/bn-bd.json index fb414f10a..6b4ea4285 100644 --- a/src/lang/bn-bd.json +++ b/src/lang/bn-bd.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/cs-cz.json b/src/lang/cs-cz.json index 863c5b3db..3709e5aca 100644 --- a/src/lang/cs-cz.json +++ b/src/lang/cs-cz.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/de-de.json b/src/lang/de-de.json index b56e1ec6c..60c7ecc6f 100644 --- a/src/lang/de-de.json +++ b/src/lang/de-de.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/en-us.json b/src/lang/en-us.json index 3238f6321..57cd7f93e 100644 --- a/src/lang/en-us.json +++ b/src/lang/en-us.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/es-sv.json b/src/lang/es-sv.json index 5225db925..7459900c7 100644 --- a/src/lang/es-sv.json +++ b/src/lang/es-sv.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/fr-fr.json b/src/lang/fr-fr.json index 7a86b01e8..e156a9804 100644 --- a/src/lang/fr-fr.json +++ b/src/lang/fr-fr.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/he-il.json b/src/lang/he-il.json index 8896dfb34..69b05affb 100644 --- a/src/lang/he-il.json +++ b/src/lang/he-il.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/hi-in.json b/src/lang/hi-in.json index 9be4b9356..ad301f395 100644 --- a/src/lang/hi-in.json +++ b/src/lang/hi-in.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/hu-hu.json b/src/lang/hu-hu.json index ee9008221..9dfc685b0 100644 --- a/src/lang/hu-hu.json +++ b/src/lang/hu-hu.json @@ -913,5 +913,6 @@ "error-no-space": "Ezen az eszközön nincs elegendő szabad tárhely.", "error-network": "Nem sikerült kapcsolódni a kiszolgálóhoz. Ellenőrizze az internetkapcsolatát, majd próbálja meg újra.", "files saved count": "{count} fájl mentve", - "files not saved count": "{count} fájl nem lett mentve" + "files not saved count": "{count} fájl nem lett mentve", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/id-id.json b/src/lang/id-id.json index 1bd0bc82f..2e015d071 100644 --- a/src/lang/id-id.json +++ b/src/lang/id-id.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/index.d.ts b/src/lang/index.d.ts index 13130f14a..87454845a 100644 --- a/src/lang/index.d.ts +++ b/src/lang/index.d.ts @@ -917,6 +917,7 @@ declare type LangStrings = { "error-network": string; "files saved count": string; "files not saved count": string; + "replace all confirm": string; }; declare var strings: LangStrings; diff --git a/src/lang/ir-fa.json b/src/lang/ir-fa.json index b45b7a84c..e496d5b98 100644 --- a/src/lang/ir-fa.json +++ b/src/lang/ir-fa.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/it-it.json b/src/lang/it-it.json index d9cfafd2a..734372d24 100644 --- a/src/lang/it-it.json +++ b/src/lang/it-it.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/ja-jp.json b/src/lang/ja-jp.json index ca628d562..d495cb79a 100644 --- a/src/lang/ja-jp.json +++ b/src/lang/ja-jp.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/ko-kr.json b/src/lang/ko-kr.json index 40d87180f..2b2c2f3aa 100644 --- a/src/lang/ko-kr.json +++ b/src/lang/ko-kr.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/ln-ln.json b/src/lang/ln-ln.json index 8ee84d57e..76c099ab8 100644 --- a/src/lang/ln-ln.json +++ b/src/lang/ln-ln.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/ml-in.json b/src/lang/ml-in.json index 031631306..a734a3be5 100644 --- a/src/lang/ml-in.json +++ b/src/lang/ml-in.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/mm-unicode.json b/src/lang/mm-unicode.json index 5cffc0d15..1083f951a 100644 --- a/src/lang/mm-unicode.json +++ b/src/lang/mm-unicode.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/mm-zawgyi.json b/src/lang/mm-zawgyi.json index 41108562d..f539e6768 100644 --- a/src/lang/mm-zawgyi.json +++ b/src/lang/mm-zawgyi.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/pl-pl.json b/src/lang/pl-pl.json index 5f10f2866..52b1de582 100644 --- a/src/lang/pl-pl.json +++ b/src/lang/pl-pl.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/pt-br.json b/src/lang/pt-br.json index a7625de48..decee53d4 100644 --- a/src/lang/pt-br.json +++ b/src/lang/pt-br.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/pu-in.json b/src/lang/pu-in.json index 02592449a..db800e376 100644 --- a/src/lang/pu-in.json +++ b/src/lang/pu-in.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/ru-ru.json b/src/lang/ru-ru.json index c5669b134..7178f0237 100644 --- a/src/lang/ru-ru.json +++ b/src/lang/ru-ru.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/tl-ph.json b/src/lang/tl-ph.json index b898659b0..8e78f0af9 100644 --- a/src/lang/tl-ph.json +++ b/src/lang/tl-ph.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/tr-tr.json b/src/lang/tr-tr.json index c7a2e03b6..4ad5016dd 100644 --- a/src/lang/tr-tr.json +++ b/src/lang/tr-tr.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/uk-ua.json b/src/lang/uk-ua.json index a587bdb34..a9814d28d 100644 --- a/src/lang/uk-ua.json +++ b/src/lang/uk-ua.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/uz-uz.json b/src/lang/uz-uz.json index 83bafe77b..00f3556df 100644 --- a/src/lang/uz-uz.json +++ b/src/lang/uz-uz.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/vi-vn.json b/src/lang/vi-vn.json index a9301a242..481df7974 100644 --- a/src/lang/vi-vn.json +++ b/src/lang/vi-vn.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/zh-cn.json b/src/lang/zh-cn.json index 689fbd809..887403618 100644 --- a/src/lang/zh-cn.json +++ b/src/lang/zh-cn.json @@ -913,5 +913,6 @@ "error-no-space": "此设备的剩余存储空间不足。", "error-network": "无法连接到服务器。请检查网络连接后重试。", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/zh-hant.json b/src/lang/zh-hant.json index de8d89e79..c4c5f6dfb 100644 --- a/src/lang/zh-hant.json +++ b/src/lang/zh-hant.json @@ -913,5 +913,6 @@ "error-no-space": "此裝置的剩餘儲存空間不足。", "error-network": "無法連線至伺服器。請檢查網路連線後重試。", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/lang/zh-tw.json b/src/lang/zh-tw.json index 4ff63c812..1a4b77554 100644 --- a/src/lang/zh-tw.json +++ b/src/lang/zh-tw.json @@ -913,5 +913,6 @@ "error-no-space": "There isn't enough storage space left on this device.", "error-network": "Couldn't reach the server. Check your connection and try again.", "files saved count": "Files saved: {count}", - "files not saved count": "Files not saved: {count}" + "files not saved count": "Files not saved: {count}", + "replace all confirm": "Replace {matches} matches in {files} files?" } diff --git a/src/sidebarApps/searchInFiles/index.js b/src/sidebarApps/searchInFiles/index.js index 5729f1e45..2cb1fdf43 100644 --- a/src/sidebarApps/searchInFiles/index.js +++ b/src/sidebarApps/searchInFiles/index.js @@ -4,6 +4,7 @@ import autosize from "autosize"; import { getDocText } from "cm/editorUtils"; import Checkbox from "components/checkbox"; import Sidebar, { preventSlide } from "components/sidebar"; +import confirm from "dialogs/confirm"; import escapeStringRegexp from "escape-string-regexp"; import Reactive from "html-tag-js/reactive"; import Ref from "html-tag-js/ref"; @@ -25,6 +26,8 @@ const workers = []; const results = []; const filesSearched = []; const filesReplaced = []; +/** Number of files the current Replace All was confirmed for. */ +let filesToReplaceCount = 0; const $container = Ref(); const $regExp = Ref(); @@ -365,7 +368,7 @@ async function onWorkerMessage(e) { const { file, text } = data; filesReplaced.push(file); openFile(file.url, { - render: filesSearched.length === filesReplaced.length, + render: filesReplaced.length === filesToReplaceCount, text, }); break; @@ -795,7 +798,7 @@ function sendNativeSearch( case "replace-result": filesReplaced.push(event.file); openFile(event.file.url, { - render: filesSearched.length === filesReplaced.length, + render: filesReplaced.length === filesToReplaceCount, text: event.text, }); break; @@ -924,9 +927,9 @@ function withTimeout(promise, ms) { * Sends a message to the worker threads to perform the replacement. */ async function replaceAll() { - terminateWorker(); - filesReplaced.length = 0; - + // Snapshot everything before the dialog: the search keeps running while it + // is open, so only the files the user was shown may be replaced. + const files = [...filesSearched]; const search = $search.value; const replace = $replace.value; const options = getOptions(); @@ -934,14 +937,24 @@ async function replaceAll() { const regex = toRegex(search, options); if (!regex) return; + if (files.length) { + const confirmed = await confirm( + strings.warning, + strings["replace all confirm"] + .replace("{matches}", resultOverview.matchesCount) + .replace("{files}", files.length), + ); + if (!confirmed) return; + } + + terminateWorker(); + filesReplaced.length = 0; + filesToReplaceCount = files.length; + replacing = true; activeReplaceTasks = 0; - const nativeFiles = filesSearched.filter((file) => - supportsNativeSearch(file.url), - ); - const workerFiles = filesSearched.filter( - (file) => !supportsNativeSearch(file.url), - ); + const nativeFiles = files.filter((file) => supportsNativeSearch(file.url)); + const workerFiles = files.filter((file) => !supportsNativeSearch(file.url)); if (nativeFiles.length) { activeReplaceTasks += 1; sendNativeSearch("replace", nativeFiles, search, options, replace);