Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adjust GetBackwardWordAmount and GetForwardWordAmount to take symbols into account #6496

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

AleXu224
Copy link

Fixes #6483

osu.Framework.Tests_4dKSD5KYp0.mp4

@peppy
Copy link
Member

peppy commented Jan 20, 2025

Seems logical.

@smoogipoo
Copy link
Contributor

When selecting forward words, it should also select the symbol (using macOS as example here, don't have Windows to test with atm):

Screen.Recording.2025-01-21.at.14.04.09.mov
Screen.Recording.2025-01-21.at.14.04.31.mov

Comment on lines 456 to 464
// Skip one character if it is a symbol to avoid cases like "author=<cursor>" requiring two taps
if (isCharacterSymbol(text[searchPrev]))
searchPrev--;

if (searchPrev <= 0) return -selectionEnd;

Func<char, bool> searchFunc = isCharacterSymbol(text[searchPrev]) ? isCharacterSymbol : isCharacterAlphanumeric;
while (searchPrev > 0 && searchFunc(text[searchPrev]))
searchPrev--;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function in general is quite hard to understand and prove for correctness, imo. I wonder if all of these can be combined into the one while loop? Maybe including the whitespace case from above?

Here's another weird case (multiple symbols before alphanumeric):

Screen.Recording.2025-01-21.at.14.11.29.mov
Screen.Recording.2025-01-21.at.14.11.44.mov

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I combined it all under a single loop and tried to make it easier to understand. Please let me know if it is alright now

osu.Framework/Graphics/UserInterface/TextBox.cs Outdated Show resolved Hide resolved
@AleXu224
Copy link
Author

When selecting forward words, it should also select the symbol (using macOS as example here, don't have Windows to test with atm):
Screen.Recording.2025-01-21.at.14.04.09.mov
Screen.Recording.2025-01-21.at.14.04.31.mov

When making this PR I used Visual Studio Code as a reference, sadly it looks like the way this is implemented in apps is inconsistent.
I just tested it in firefox, notepad++, discord and vscode and they all had different behavior.
It looks like you are using a browser search bar to test it, should I copy the way that does it or stick with the current implementation ?

@peppy
Copy link
Member

peppy commented Jan 22, 2025

It looks like you are using a browser search bar to test it, should I copy the way that does it or stick with the current implementation ?

I'd just choose one and go with it. Probably matching smoogi's proposal is fine until someone has a problem with it. It's not important in the scheme of things.

@smoogipoo
Copy link
Contributor

Ah jeez, I didn't realize everything handles it differently. I was testing Firefox, but it also handles it differently compared to TextEdit/Safari... As long as it's consistent is fine then, I think the examples I pointed out are still showing inconsistency.

@AleXu224
Copy link
Author

Alright, I have updated the logic to match your examples above. Thank you for your feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Make Ctrl+Backspace break on symbols
3 participants