- AuthorPosts
- June 18, 2025 at 10:10 am #30294
Patrick C
ParticipantIssue
Select one character (selection size 1).
Find the same character within the selection.Effect
✔ Works when using the find dialogue.
✘ Fails when usingdocument.selection.Find(…, eeFindNext | eeFindReplaceSelOnly);
Example
Increasing the selection’s size to 2 or more works in both cases.
Code for testing:
Example code requiring manually selecting d
Longer example code automatically selecting dJune 19, 2025 at 5:25 am #30295Patrick C
ParticipantI spent a bit more time on this and it seems that Find in the Selection Only has some additional quirks.
1) EmEditor doesn’t update the search range when selecting a new one.
2) EmEditor collapses the selection when it contains only one character (found or not).In the following examples the macro code is:
nFound = document.selection.Find("d", eeFindNext | eeFindReplaceSelOnly); status = "nFound = " + nFound;
And the find dialogue settings are:
Example 1: EmEditor search range.
In the following example EmEditor incorrectly uses the previous search range when searching in a new search range.
1) Restart EmEditor
2) Select the left abcd.
3) Find d in the selection (dialogue or macro). → Selects the left d ✔
4) Select the right abcd.
5) Find d in the selection (dialogue or macro). → Selects the left d 🤔
→ EmEditor used the previous search range rather than the current one.Example 2: EmEditor one character selection collapse.
1) Restart EmEditor
2) Select one character, e.g. d
3) Find d in the selection → the selection collapses 🤔 (inconsistent with point 5 below).
4) Restart EmEditor
5) Select two characters, e.g. cd
6) Find d in the selection → the selection does not collapse (my preferred behaviour).
Btw: When selecting cd and searching for cd, the selection also doesn’t collapse, which is the expected (and in my case preferred) behaviour.June 21, 2025 at 8:48 am #30296Yutaka Emura
KeymasterThe dialog box includes a Count Matches option. To achieve the same result in your macro, make sure to include the
eeFindCount
flag.
Using the macro below will give you the same outcome:nFound = document.selection.Find("d", eeFindNext | eeFindReplaceSelOnly | eeFindCount);
June 22, 2025 at 1:42 am #30303Patrick C
ParticipantAh 😀 💡, thanks for pointing this out! And sorry, I should have noticed myself.
This basically means that finding in a one character selection fails with both the search dialogue and the macro:
June 22, 2025 at 8:18 am #30304Yutaka Emura
KeymasterThis basically means that finding in a one character selection fails with both the search dialogue and the macro:
That’s because the selection exactly matches the search string. In this case, the command tries to find the next occurrence, but since there isn’t one, the search fails.
June 22, 2025 at 9:05 am #30305Patrick C
ParticipantNow I get it, and the behaviour is consistent.
When, for example, selecting «cde» and searching for «cde» in the selection, the search also fails.
Thank you for clarifying 😃.
I’ve just purchased an annual subscription. While I’ve been on a lifetime licence since 2015, I thought it was time to say thank you for 10 years of support.June 22, 2025 at 6:55 pm #30306Yutaka Emura
KeymasterWe appreciate your support!
- AuthorPosts
- You must be logged in to reply to this topic.