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

Markers in empty elements can cause unexpected errors #8092

Closed
pomek opened this issue Sep 16, 2020 · 0 comments · Fixed by #8797 or #9133
Closed

Markers in empty elements can cause unexpected errors #8092

pomek opened this issue Sep 16, 2020 · 0 comments · Fixed by #8797 or #9133
Assignees
Labels
package:engine squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.

Comments

@pomek
Copy link
Member

pomek commented Sep 16, 2020

The problem occurred for the first time in #7907.


We agreed that the bug can be hooked deeper, in the engine. However, the PR fixes the bug and the editor does not crash anymore.

As for now, we're fine with that. But in the future, the bug can occur once again and if we will be fixing that, we should revert changes introduced in the PR.

model.change( writer => {
const range = model.document.selection.getFirstRange();
if ( model.markers.has( VISUAL_SELECTION_MARKER_NAME ) ) {
writer.updateMarker( VISUAL_SELECTION_MARKER_NAME, { range } );
} else {
if ( range.start.isAtEnd ) {
const focus = model.document.selection.focus;
const nextValidRange = getNextValidRange( range, focus, writer );
writer.addMarker( VISUAL_SELECTION_MARKER_NAME, {
usingOperation: false,
affectsData: false,
range: nextValidRange
} );
} else {
writer.addMarker( VISUAL_SELECTION_MARKER_NAME, {
usingOperation: false,
affectsData: false,
range
} );
}
}
} );

Originally posted by @pomek in #8074 (comment)

@pomek pomek added the squad:core Issue to be handled by the Core team. label Sep 16, 2020
@pomek pomek added this to the unknown milestone Sep 16, 2020
@mlewand mlewand added package:engine type:bug This issue reports a buggy (incorrect) behavior. labels Sep 16, 2020
@Reinmar Reinmar modified the milestones: unknown, iteration 36 Sep 18, 2020
@mlewand mlewand self-assigned this Sep 23, 2020
@Reinmar Reinmar modified the milestones: iteration 36, iteration 37 Sep 28, 2020
@AnnaTomanek AnnaTomanek modified the milestones: iteration 37, nice-to-have Oct 19, 2020
@niegowski niegowski assigned niegowski and unassigned mlewand Jan 8, 2021
@niegowski niegowski modified the milestones: nice-to-have, iteration 39 Jan 8, 2021
scofalik added a commit that referenced this issue Jan 15, 2021
Other (link): Fake selection marker for collapsed and non-collapsed selections for link UI should be converted separately. Closes #8092.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package:engine squad:core Issue to be handled by the Core team. type:bug This issue reports a buggy (incorrect) behavior.
Projects
None yet
5 participants