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

getNearestSelectionPosition changes #717

Merged
merged 6 commits into from
Dec 14, 2016
Merged

getNearestSelectionPosition changes #717

merged 6 commits into from
Dec 14, 2016

Conversation

szymonkups
Copy link
Contributor

@szymonkups szymonkups commented Dec 8, 2016

… to getNearestSelectionRange. Added tests and required fixes to other methods using this.
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.

I'm a bit short on time now, so I made a short review too.

selection.setRanges( insertion.getSelectionRanges() );
const newRange = insertion.getSelectionRange();

/* istanbul ignore else */
Copy link
Member

Choose a reason for hiding this comment

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

I'd like to have every case like this commented. We're not testing else because it's a safe check for some unpredictable edge cases. Also, having a log.warning() would be good there, like in the other cases in this method.

* * `forward` - searching will be performed only forward,
* * `backward` - searching will be performed only backward.
*
* When valid selection range cannot be found, `null` value is returned.
Copy link
Member

Choose a reason for hiding this comment

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

"null is returned"

if ( this.schema.check( { name: '$text', inside: step.value.nextPosition } ) ) {
return step.value.nextPosition;
}
for ( let data of getWalkersData( backwardWalker, forwardWalker ) ) {
Copy link
Member

Choose a reason for hiding this comment

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

Walker has no data. Walker walks ;). Maybe combineWalkers()?

@szymonkups
Copy link
Contributor Author

Added requested fixes.


test(
'should return null if there is no valid range',
'<image></image>',
Copy link
Member

Choose a reason for hiding this comment

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

This case is a bit strange. Isn't this pattern missing initial selection? And if it does, shouldn't the image be selected?

Copy link
Member

Choose a reason for hiding this comment

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

OK... Image is not an object in this test suite. This is confusing. Could we name it like... damn, I can't find a name, because this case shouldn't really occur :D. Perhaps we can call it <emptyBlock> then?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This case should be changed indeed. Initial selection should be added.

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.

Just a minor thing to correct in the tests.

@szymonkups
Copy link
Contributor Author

Added requested changes.

@Reinmar
Copy link
Member

Reinmar commented Dec 14, 2016

There's a warning logged by the tests:

WARN: 'insertcontent-no-range: Cannot determine a proper selection range after insertion.', undefined

See https://travis-ci.org/ckeditor/ckeditor5-engine/builds/183855169

If it's expected that it's logged, it should be stubbed. If not, then it means that either we don't need that istanbul comment or that something works incorrectly.

@Reinmar Reinmar merged commit c512851 into master Dec 14, 2016
@Reinmar Reinmar deleted the t/712 branch December 14, 2016 10:39
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
2 participants