Notepad2e
Notepad2e copied to clipboard
Ctrl+Shift+* - search for word
Menu items:
- Edit | Find Next Word after Replace Next
- Edit | Find Previous Word after Find Next Word
In vim, you can type aa bb aa aa, position caret at middle aa, press * or # to position caret at next or preceding aa (so at |aa bb aa aa or aa bb aa |aa).
Need to:
- See if Ctrl+* and Ctrl+Shift+* hotkeys are available
- Make them work like in vim: we already highlight "word" under cursor; the same definition of "word" should be used to find next/previous occurrence of this word in the document (not limited to visible screen portion). The search should wrap around. The word should be selected after search. If there's no word in the entire document nothing happens.
Essentially this must be identical to using Ctrl+F Find dialog but with a single hotkey. Example:
- Make new document with text
aa bb aa aa - Position caret at the beginning
- Press Ctrl+*
- You get this selection:
aa bb [aa] aa - Press Ctrl+Shift+*
- You get this selection:
[aa] bb aa aa - Press Ctrl+Shift+*
- You get this selection:
aa bb aa [aa]
You could achieve the same effect by:
- Selecting first
aato get[aa] bb aa aa - Pressing Ctrl+F - the input would contain
aa - Pressing Enter
- Getting this selection:
aa bb [aa] aa - Or instead of Enter you could press Alt+P to trigger Find Previous and you'd get
aa bb aa [aa]
fixed
but you must specify about text case ...( it's ignored in this implementation)
it's ignored in this implementation
It's correct. I've tested and it works good except that hotkeys don't work (menu items work okay) - Ctrl+* and Ctrl+Shift+* do nothing.
Ctrl+* and Ctrl+Shift+* do nothing
they do everything for me =) ... may be U use * not on digital keyboard ? I use it. May be u wanna use Ctrl+8 and Ctrl+Shift+8 (there is a another '*' under '8' ) ?
in this implementation i use MULTIPLY symbol from digital keyboard
Yes, exactly - Ctrl+8. No need for numeric keyboard's star.
fixed
One minor thing: can you change the name of hotkey in the menu from saying * to say 8? Because it doesn't work on Ctrl+* anymore so let it be Ctrl+8 and Ctrl+Shift+8.
fixed
Bug: Ctrl+8 doesn't add word to Find search list so F3 doesn't continue searching for this word.
Essentially this must be identical to using Ctrl+F Find dialog but with a single hotkey.
Please also consider this addition: when there's no word at cursor (by your definition of "word" - e.g. in stuff |$var where | = caret) seek right (Ctrl+8) or left (Ctrl+Shift+8) to find first word symbol (a-z, etc.) and if found do the regular search as described in this ticket. Limit this search to about 250 symbols/bytes (whatever is more convenient for you to code) at most, give up if no word found. Do not wrap around (to the doc beginning or doc end if Shift is used).
In other words make it auto-seek to the first word on the right/left of the current caret position and at most up to ~250 after/before the caret.
stuff |$var stuff var
- Caret at
| - Ctrl+8
- Must move to
stuff $var stuff |var|
stuff |$var stuff var
- Caret at
| - Ctrl+Shift+8
- Must move to
|stuff| $var stuff var
$| stuff $var stuff var
- Caret at
| - Ctrl+Shift+8
- Must do nothing (no word of the left of
$)
Bug: Ctrl+8 doesn't add word to Find search list so F3 doesn't continue searching for this word.
fixed
Please also consider this addition
not completed yet. But you can play with it =) ... it is more tough that i thought before
not completed yet. But you can play with it =) ... it is more tough that i thought before
Actually your current implementation has given me a better explanation idea: instead of seeking to a word and then searching you should do this:
- Let's take current algorithm that was before my last post) - without word seeking
- Now let's make it if and only if caret s not at "word" and Ctrl+[Shift]+8 is pressed then you should seek for the closest word as described, select it and stop right there (i.e. don't seek further).
In other words if I use Ctrl+8 and my caret isn't positioned on a word then you should find that word (to the right of caret for Ctrl+8 or to the left for Ctrl+Shift+8), select it and stop. You should have a limit like described to so it doesn't rummage through a multimegabyte doc in vain.
If my caret is at any word then you should find and select next (Ctrl+8) or previous (Ctrl+Shift+8) word just like you have already done.
If this would help you can check the implementation of Ctrl+Space: what I want is 100% identical to what currently happens if you have a caret positioned not at a "word" and when you press Ctrl+Space - Notepad2 seeks to the right, finds first word symbol, seeks further to find first non-word symbol and selects text in between (including the first word symbol but without first non-word symbol).
Example:
aa |$foo
- Caret at
| - Ctrl+Space
aa $|foo|
I want exactly the same with Ctrl+8. Ctrl+Shift+8 must be exactly the same too but backwards: aa |$foo → Ctrl+Shift+8 → |aa| $foo.
The only difference is that if Ctrl+Space finds no word until the document or line end it will select the entire line. Instead of this I want to seek to the next line (up to ~250 limit as described) or if there're no words up until doc ends - do/select nothing.
fixed // test it please
If there are no occurrences of a word you still select it.
- Input =
aa |$bb aa - Ctrl+8
- Input =
aa |$bb| aa
Same with Ctrl+Shift+8. But it works correctly if caret is at the word (i.e. no selection occurs). Only wrong when you are seeking for nearby word.
If there are no occurrences of a word you still select it.
It is not a bug...Let's test last revision about this case ... it's not easy to understand
- text: aa | bb bb
- Ctrl+8
- Do you want select first bb or second?
Last revision is the same. The problem is that your example is correct but it differs from mine: aa | bb bb - Ctrl+8 - you select first bb which is correct.
But compare to this: aa aa | bb - Ctrl+8 - you still select bb. But why? It's just one word occurrence, no need to do anything.
fixed ( it was my bad )
You should to test it thoroughly... i see a lot of cases here
Seems to work. I can't test it 100% right now, most bugs are uncovered during real usage so you can expect something to fix later :)
Strange bug:
public |$foo;
$foo = 123;
$foo = 345;
Cursor before first $. Ctrl+8. foo on the line with 123 gets selected. This is correct. Now F3. This time $foo with 345 gets selected which is not correct - $ should not be included in the selection. In other words:
$[foo] = 123;
[$foo] = 345;
Should be:
$[foo] = 123;
$[foo] = 345;
If you go to Find after F3 you will see that Search String is set to $foo instead of foo.
Fixed by @cshnik in dev, mechanism changed.
This feature needs to be revisited:
- it's currently independent of normal F3 find - make it partially dependent:
- when called, Find Word adds current search term to F3's history (so after Find Word F3 will search the same string)
- if there is no selection, Find Word takes closest word - keep this; when there is selection, Find Word currently uses last search - this is removed, make it search for selection instead (like F3 does)
- as a consequence, there is no more need to remember last Find Word search string in code
Done.
when called, Find Word adds current search term to F3's history
This works.
(so after Find Word F3 will search the same string)
This doesn't - F3 doesn't "see" the search term added by Ctrl+8.
if there is no selection, Find Word takes closest word
This works.
there is selection, Find Word currently uses last search - this is removed, make it search for selection instead (like F3 does)
This doesn't.
Fixed.
When there is no selection, Find Next Word takes closest word on the right. Make Find Previous Word do the same (currently it takes word on the left).
When there is no selection, Find Next Word takes closest word on the right. Make Find Previous Word do the same (currently it takes word on the left).
Fixed.
It seems FindWord... settings are no longer respected: https://github.com/ProgerXP/Notepad2e#findwordmatchcase--findwordwraparound
It seems FindWord... settings are no longer respected
Cannot reproduce.
In my local tests both FindWordMatchCase/FindWordWrapAround options work as expected when using search for word-commands. Please provide your exact scenario if the problem remains.
In my local tests both
FindWordMatchCase/FindWordWrapAroundoptions work as expected when usingsearch for word-commands.
FindWordWrapAround works but FindWordMatchCase doesn't - the search is always case-insensitive:
aa AA
aa|
Ctrl+Shift+8 selects AA unless Find's Match case is checked (Find Word must be independent of it).
The Match whole word only flag is always enabled for those commands so it can't be customized. https://github.com/ProgerXP/Notepad2e#findwordmatchcase--findwordwraparound
This is no longer the case:
aa| aaa
Ctrl+8 selects [aa]a unless Find's Match word is checked (Find Word must be independent of it).
To summarize, currently only FindWordWrapAround is independent and works as expected. And they can't really work because searchflags is never passed to n2e_FindTextImpl():
https://github.com/ProgerXP/Notepad2e/blob/aae749400bd1d12ccfde62c92ae212d855c002df/src/Extension/EditHelper.c#L375-L387
Please review the code of this issue, it's very tangled. Maybe it's worth refactoring.
Fixed.