Notepad2e
Notepad2e copied to clipboard
Always select closest word
This is likely a Scintilla feature.
Document with two lines (| indicate cursor positions):
| aa bb
| 'aa bb
Place cursor at line 1, Ctrl+Space - aa will be selected. This is good.
Place cursor at line 2, Ctrl+Space - the entire line will be selected. This is bad - it should behave as line 1, i.e. locate the closest word by right-scanning and then select it. For selecting a line there is Ctrl+Shift+Space hotkey.
In other words, for both lines selection should be the same.
Place cursor at line 1, Space - aa will be selected. This is good.
Cannot reproduce.
Press on Space-key should insert whitespace character (0x20) and will move whole line to the right. I can't get how it may affect current document selection. Please provide your INI file and animation GIF (if possible).
Sorry, I entirely missed the modifier - it's a hotkey, thus it's Ctrl+Space for "select word" (and Ctrl+Shift+Space for "select line").
Fixed.
Extend this behaviour so that it works left-side too. Document:
aa bb ' |
Ctrl+Space currently selects the entire line. Instead, make it select closest left-side word (bb), or if there's none - do nothing. Make it the same for right-side scanning (in the first post in this issue), i.e. when there is no close word - do nothing, do not select the line.
Ctrl+Space will never select a complete line after this change.
Fixed.
Document: ¶
Press Ctrl+Space - the program hangs.
Fixed.
48300c9 introduced a subtile change: Ctrl+Space no longer selects word on the next line. Consider this document:
first
|
third
Ctrl+Space used to select third, now it selects nothing. Adjust implementation to allow right-scanning over newlines (it's okay to have a hardcoded limit on this, like 10000 bytes/characters).
After this, Ctrl+Space still won't select anything for this document:
first
|
But it will select third for this:
|
third
Fixed.
No right-scanning text limit is required since algorithm uses Scintilla`s standard SCI_WORDENDPOSITION-message.
Must skip non-word symbols in the same way as implemented for the same-line selection:
|
// foo
Result:
// [foo]
Additionally, trying next line should be done only if there is no word on the same line:
a.|
b
Currently, Ctrl+Space selects [b] but it should select [a].
Fixed.
Memo: as it was coded, in absence of any word on the left (on the same line) and on the right until EOF it moves caret to before the first column on the last non-empty line:
.|
.
. <- to here: |.
Place cursor at line 2, Ctrl+Space - the entire line will be selected. This is bad - it should behave as line 1, i.e. locate the closest word by right-scanning and then select it. For selecting a line there is Ctrl+Shift+Space hotkey.
As it was implemented by 48300c9ef8818a04869c1deb5807514eb188f4b5 https://github.com/ProgerXP/Notepad2e/issues/205#issuecomment-699536336, when there is a selection Ctrl+Space does nothing (keeps that selection). Adjust it so that it pretends selection is empty and selects the closest word near the cursor (i.e. start or end of the selection depending on caret location). If there's no word, selection is unchanged (as currently), else the word is selected (which may be the same selection or intersect with it).
For example: a[a a|]a - Ctrl+Space: aa [aa|] - Ctrl+Space: aa [aa|] (same).
Another: a[|a a]a or a|a aa or |aa aa or aa| aa - Ctrl+Space (and subsequent): [aa|] aa.
One case when this is more useful than the current behaviour is doing a Find on a word's part in order to change it (e.g. change case) - currently you have to press arrow left or right to clear the located selection, then Ctrl+Space.
Done.
[|
aa]
Currently, pressing Ctrl+Space clears the selection. Pressing it again selects [aa]. It should select that on the first keystroke.
Fixed.