Skip to content
This repository has been archived by the owner on Jun 26, 2020. It is now read-only.

I/6501: Handle intersecting ranges when fixing graveyard selection #1834

Merged
merged 8 commits into from
Apr 14, 2020

Conversation

jodator
Copy link
Contributor

@jodator jodator commented Mar 31, 2020

Suggested merge commit message (convention)

Fix: Intersecting ranges resulting when fixing graveyard selection no longer breaks the editor. Closes ckeditor/ckeditor5#6501. Closes ckeditor/ckeditor5#6382.


Additional information

PR to merge together: ckeditor/ckeditor5-table#293.

Well, it looks like intersecting ranges will be created on such modifications as in tables: multi-range selection set on table cells and their parent is removed. This would result in many ranges being fixed to the same range (thus intersecting with any other fixed range).

As with other ranges/positions fixes, I am not sure if I have a broad view of this problem. The proposed solution fixes this case and does not break other CKEditor 5 tests buuuut we do not have every case tested.

@coveralls
Copy link

coveralls commented Mar 31, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling c0364a2 on i/6501 into 08e8294 on master.

@@ -1778,6 +1778,63 @@ describe( 'DocumentSelection', () => {
// Now it's clear that it's the default range.
expect( selection.getFirstPosition().path ).to.deep.equal( [ 0, 0 ] );
} );

it( 'does not break if multi-range selection is inside text nodes', () => {
Copy link
Member

Choose a reason for hiding this comment

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

"Does not break" does not explain what should actually happen. I prefer explaining what's the expected result.

Suggested change
it( 'does not break if multi-range selection is inside text nodes', () => {
it( 'handles multi-range selection in a text node by merging it into one range', () => {

Copy link
Member

Choose a reason for hiding this comment

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

BTW, as mentioned in the test description – I'd actually expect the ranges to be merged if they are identical. Would that require a lot of work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'd actually expect the ranges to be merged if they are identical.

I don't see a need to merging two identical ranges. With intersecting ones I would  have to check.

expect( selection.getLastPosition().path ).to.deep.equal( [ 1, 1 ] );
} );

it( 'does not break if multi-range selection is set on object nodes and resulting ranges will intersect', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Again – explain what's expected.

expect( selection.getLastPosition().path ).to.deep.equal( [ 1, 1 ] );
} );

it( 'does not break if multi-range selection is set on object nodes and resulting ranges will intersect', () => {
Copy link
Member

Choose a reason for hiding this comment

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

Again – explain what's expected.

Copy link
Member

@Reinmar Reinmar left a comment

Choose a reason for hiding this comment

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

As commented – I think that in the text node case, the ranges should be merged too. Also, test descriptions could be better.

@Reinmar Reinmar merged commit c208ce1 into master Apr 14, 2020
@Reinmar Reinmar deleted the i/6501 branch April 14, 2020 10:31
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
3 participants