Browse Source

Update comment in tryFixingNonCollapsedRage() of selection-post-fixer.

Maciej Gołaszewski 7 years ago
parent
commit
ade95f9e38
1 changed files with 5 additions and 1 deletions
  1. 5 1
      packages/ckeditor5-engine/src/model/utils/selection-post-fixer.js

+ 5 - 1
packages/ckeditor5-engine/src/model/utils/selection-post-fixer.js

@@ -192,7 +192,11 @@ function tryFixingNonCollapsedRage( range, schema ) {
 			const isEndObject = end.nodeBefore && schema.isObject( end.nodeBefore );
 			const fixedEnd = isEndObject ? null : schema.getNearestSelectionRange( end, 'backward' );
 
-			return new Range( fixedStart ? fixedStart.start : start, fixedEnd ? fixedEnd.start : end );
+			// The schema.getNearestSelectionRange might return null - if that happens use original position.
+			const rangeStart = fixedStart ? fixedStart.start : start;
+			const rangeEnd = fixedEnd ? fixedEnd.start : end;
+
+			return new Range( rangeStart, rangeEnd );
 		}
 	}