New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display number of instances found on find status label #685
Comments
I considered this, but it complicates the search and makes the results less predictable (performance-wise) on large documents as it either needs to count instances on the first (each?) search or to do it in the background and then present the result. While I agree it's convenient to have, either options doesn't really sound appealing to me. When the user selects multiple instances, the number of instances is shown in the status bar: What I can probably do is to keep track of visited instances and when a full loop is complete, show the number of instances (since all of them should be visited). |
That should work as well |
@pkulchenko Today i remembered, i am using the highlightselected plugin, maybe this feature could be implemented on the plugin instead, since it searches for all instances itself? |
@CetoBasilius, try this patch to highlightselected: diff --git a/highlightselected.lua b/highlightselected.lua
index 76cce40..0ad4005 100644
--- a/highlightselected.lua
+++ b/highlightselected.lua
@@ -6,7 +6,7 @@ return {
name = "Highlight selected",
description = "Highlights all instances of a selected word.",
author = "Paul Kulchenko",
- version = 0.16,
+ version = 0.17,
dependencies = "1.11",
onRegister = function() ide:AddIndicator(indicname) end,
@@ -52,7 +52,7 @@ return {
local flags = editor:GetSearchFlags()
editor:SetSearchFlags(wxstc.wxSTC_FIND_WHOLEWORD + wxstc.wxSTC_FIND_MATCHCASE)
- local pos = 0
+ local pos, num = 0, 0
while true do
editor:SetTargetStart(pos)
editor:SetTargetEnd(length)
@@ -61,7 +61,9 @@ return {
editor:IndicatorFillRange(pos, #value)
pos = pos + #value
+ num = num + 1
end
+ ide:SetStatusFor(("Found %d instance(s)."):format(num), 5)
editor:SetSearchFlags(flags)
end,
} |
Yes! that works great! Any plans on pushing to the main packages repository? |
Yes, will do shortly. |
Perfect. Thank you very much, @pkulchenko keep up the great work! |
When searching for a text, the only status displayed is when the search reaches the end of text and wraps around. As an enhancement, it would be nice to see how many results were found, if possible.
This would be helpful in some cases where we need to check how many times a function gets called or how many times a certain string is being used in some data structures.
calling the SetStatus function i was able to make a mock of the feature, something like this:
The text was updated successfully, but these errors were encountered: