From 522d8a80942d78488dd504f48395fe67e3986492 Mon Sep 17 00:00:00 2001 From: Guldoman Date: Thu, 23 Jun 2022 00:15:20 +0200 Subject: [PATCH] `findreplace`: Fix number of total replacements --- data/core/commands/findreplace.lua | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/data/core/commands/findreplace.lua b/data/core/commands/findreplace.lua index 584d4f67..642c4c0f 100644 --- a/data/core/commands/findreplace.lua +++ b/data/core/commands/findreplace.lua @@ -108,9 +108,13 @@ local function replace(kind, default, fn) submit = function(new) core.status_view:remove_tooltip() insert_unique(core.previous_replace, new) - local n = doc():replace(function(text) + local results = doc():replace(function(text) return fn(text, old, new) end) + local n = 0 + for _,v in pairs(results) do + n = n + v + end core.log("Replaced %d instance(s) of %s %q with %q", n, kind, old, new) end, suggest = function() return core.previous_replace end,