#30295
Patrick C
Participant

I 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;

Macro find in selection code

And the find dialogue settings are:
Find dialogue settings

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.
Left abcd selected
3) Find d in the selection (dialogue or macro). → Selects the left d ✔
Found and selected the left d :)
4) Select the right abcd.
Right abcd selected
5) Find d in the selection (dialogue or macro). → Selects the left d 🤔
Found and selected the d on the left instead of the one on the right
→ 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
Selected d
3) Find d in the selection → the selection collapses 🤔 (inconsistent with point 5 below).
Find collapsed the selection
4) Restart EmEditor
5) Select two characters, e.g. cd
Selected cd
6) Find d in the selection → the selection does not collapse (my preferred behaviour).
Find selected d
Btw: When selecting cd and searching for cd, the selection also doesn’t collapse, which is the expected (and in my case preferred) behaviour.