-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Refactor the way 2SCM support multiple attributes. Enable it for code. #7577
Conversation
as the multi-attribute caret handling needs to be orchestrated by TwoStepCaretMovement class. Avoid exposing implementation details into API for no specific reason.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now I had some question about the base PR which might slightly change this PR.
However, the whole thing goes in good direction and the refactor is OK after a first brief review.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SO the previous comment is sustained. I don't see anything that might block this PR.
I have some follow ups, though:
Suggested merge commit message (convention)
Other (typing, basic-styles): Enable two-step caret movement for Code, refactor the way it handles multiple attributes. Closes #6722. Closes #7578.
MINOR BREAKING CHANGE (typing):
TwoStepCaretHandler
class was removed.Additional information
1. Behavioral change #7578
I think the current behavior in regards of moving between different attributes is counter-intuitive.
<i>foo[]</i><b>bar</b>
moves to the<i>foo</i><b>[]bar</b>
<a href="f">foo[]</a><a href="b">bar</a>
moves to the<a href="f">foo</a>[]<a href="b">bar</a>
As a user, I find this inconsistency confusing.
You are able to type in between the same attribute but different values, but not between two different attributes.
If it would be inconsistent, I 'd rather make it the other way around. If it's the same attr, I'd just move between attribute values, not insert a character without any value. Then, as switching between entire attrs drops the first attribute anyway, I could expect writing attr-free here.
Needless to mention, that such inconsistency requires way more complicated code.
2. Tests
I do not want to duplicate tests from
TwoStepCaretMovement
andInlineHighLight
toCodeEditing
. I was considering having extensive tests for 2SCM and highlight alone, then tests thatCodeEditing
uses these APIs correctly and some basic high-level tests for Code.Currently, with
TwoStepCaretMovement
andLinkEditing
, it's set up in the wat 2SCM has extensive tests, Link Editing has only ~two tests for basics, but no tests that it actually uses 2SCM or inline highlight API.The idea was dismissed at https://cksource.slack.com/archives/C03URJ97S/p1593637492006600.
3. right-to-left
Previously there was only 1 test for RTL case, which was testing that some private method is called. With this PR, I replace it with 1 test for basic use-case behavior, closer to the user perspective. If we want to have full RTL coverage, I'd rather refactor the tests to generate the scenarios. I consider it out of the scope of this PR.