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

Refactor the way 2SCM support multiple attributes. Enable it for code. #7577

Merged
merged 17 commits into from
Jul 22, 2020

Conversation

tomalec
Copy link
Contributor

@tomalec tomalec commented Jul 8, 2020

⚠️ Please, review #7546 first.

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.

  • moving right from <i>foo[]</i><b>bar</b> moves to the <i>foo</i><b>[]bar</b>
  • moving right from <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 and InlineHighLight to CodeEditing. I was considering having extensive tests for 2SCM and highlight alone, then tests that CodeEditing uses these APIs correctly and some basic high-level tests for Code.

Currently, with TwoStepCaretMovement and LinkEditing, 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.

@tomalec tomalec marked this pull request as ready for review July 9, 2020 09:01
@tomalec tomalec requested a review from jodator July 14, 2020 09:36
@jodator jodator changed the base branch from master to i/7444-2SCM-refactor-highlight July 14, 2020 11:26
Copy link
Contributor

@jodator jodator left a 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.

@tomalec tomalec changed the base branch from i/7444-2SCM-refactor-highlight to master July 21, 2020 10:06
Copy link
Contributor

@jodator jodator left a 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:

@jodator jodator merged commit bbd0d6d into master Jul 22, 2020
@jodator jodator deleted the i/6722-code-2SCM branch July 22, 2020 07:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants