stb_textedit: fixed cursor movement when pressing End (without Shift) after selecting multiple-lines #1836
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Seems like a small bug that has been there from initial release.
(unless this was trying to mimick some text editor but the behavior is rather odd so this seems unlikely to me)
All text editors I have tried behave like after the fix.
Repro:
(which does not end up at end of the last selected line, otherwise issue is not noticeable)The code for Shift+STB_TEXTEDIT_K_LINEEND however works correctly and move the cursor at the right location, meaning there's a cursor moving difference between End and Shift+End, which arguably seems like a bug.
Calling
stb_textedit_move_to_last()instead ofstb_textedit_move_to_first()matches what STB_TEXTEDIT_K_RIGHT, STB_TEXTEDIT_K_WORDRIGHT paths are using.The reason IMHO it hasn't been noticed is that when doing a multi-line selection you rarely want to press End without Shift.
Thank you!