Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

markText error when using inclusiveRight/inclusiveLeft with two markers on the same line #3998

Closed
brrd opened this issue Apr 29, 2016 · 5 comments

Comments

@brrd
Copy link
Contributor

brrd commented Apr 29, 2016

Running this example on CodeMirror's homepage:

editor.setValue('a-b');
spanA = document.createElement('span'); spanA.innerText = 'A';
editor.markText({line: 0, ch: 0}, {line: 0, ch: 1}, {replacedWith: spanA, inclusiveRight: true});
spanB = document.createElement('span'); spanB.innerText = 'B';
editor.markText({line: 0, ch: 2}, {line: 0, ch: 3}, {replacedWith: spanB, inclusiveLeft: true});

The first marker is correctly rendered.
The second marker is not rendered and an error occurs: "Inserting collapsed marker partially overlapping an existing one".
When removing inclusiveRight: true or/and inclusiveLeft: true everything works fine.

It seems to be related with #2629.

This error occurs with CodeMirror 5.1.0 and 5.14.3 on Firefox and Chrome.

@marijnh
Copy link
Member

marijnh commented Apr 29, 2016

This is intentional. Collapsed/replaced markers can not partially overlap, and by having them both be inclusive on the side where they touch, they would start overlapping as soon as anything in inserted between them. So that's not allowed.

@marijnh marijnh closed this as completed Apr 29, 2016
@brrd
Copy link
Contributor Author

brrd commented Apr 29, 2016

@marijnh Thank you for your very quick reply.

Maybe I am missing something but in this example the two markers are separated by a character "-" (it could have been a longer string, the behaviour remains the same).

Does this mean that we can not render multiple markers on a single line if all of them are {inclusiveRight: true, inclusiveLeft: true}?

@marijnh
Copy link
Member

marijnh commented Apr 29, 2016

Oh, if they are not touching this should definitely be valid. I'll look into this later.

@marijnh marijnh reopened this Apr 29, 2016
@marijnh marijnh closed this as completed in 0587510 May 2, 2016
@marijnh
Copy link
Member

marijnh commented May 2, 2016

Found it. See attached patch.

@brrd
Copy link
Contributor Author

brrd commented May 3, 2016

@marijnh thank you

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants