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

Fuzzy location mapping #161

Merged
merged 3 commits into from Jan 19, 2016

Conversation

Projects
None yet
1 participant
@javan
Member

javan commented Jan 18, 2016

When re-parsing the editor's HTML, we create a location range using points because the unknown input may have removed Trix's block comment nodes. Calculating a location range from HTML with missing comment nodes would often result in the wrong cursor position after rendering. Usually off by 1, at the end of the preceding block. See #116 and #131.

Using points works well most of the time, but occasionally fails in conditions that are difficult to reproduce. This change removes the use of points, and goes back to using LocationMapper, but with a new strict: false mode that uses the containing elements to make an assumption about where a block starts. getLocationRange(strict: false) is only used by Composition#replaceHTML so all other getLocationRange calls continue to work as normal (looking for <!--block--> nodes to mark a block's start).

javan added some commits Jan 18, 2016

Improve findLocationFromContainerAndOffset to work with mutated HTML
When re-parsing the HTML, we previously created a location range using points because the unknown input may have removed Trix's block comment nodes. This worked well most of the time, but occasionally it failed in conditions that are difficult to reproduce.
@javan

This comment has been minimized.

Member

javan commented on bce8d7e Jan 18, 2016

Ugh! I introduced a subtle bug here in c830bae.

Before this fix:
remove-character-before

After:
remove-character-after

javan added a commit that referenced this pull request Jan 19, 2016

@javan javan merged commit e29c5a7 into master Jan 19, 2016

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details

@javan javan deleted the fuzzy-location-mapping branch Jan 19, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment