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

Scroll bug on lines with tabs #4602

Open
fabienferre91 opened this issue Feb 23, 2017 · 2 comments
Open

Scroll bug on lines with tabs #4602

fabienferre91 opened this issue Feb 23, 2017 · 2 comments

Comments

@fabienferre91
Copy link

fabienferre91 commented Feb 23, 2017

Go to: http://codemirror.net/demo/visibletabs.html
(Chrome Version 56.0.2924.87)

1/ Clean content
2/ Add this as the first line : 123456789 123456789 123456789 12
3/ On second line, press TAB key 16 times and add 123456789 1234567
4/ Horizontal scrollbar should appear
5/ Put cursor at the end of the second line
6/ Press DEL to remove the '7' char

=> End of second line is truncated

I dig into the source code, and I noticed that lineLength function (src/line/spans.js) doesn't take tabs into account. Maybe I misunderstood something but I have fix this with :

  function lineLength(line, tabSize) {
    if (line.height == 0) return 0;
    // take tabs into account
    var text = line.text.replace(/\t/g, Array(tabSize).fill(" "));
    var len = text.length, merged, cur = line;
@adrianheine
Copy link
Contributor

I can reproduce truncated characters with roughly the steps you described in Firefox 51. The first line has to have more characters than the second.

@peterkroon
Copy link
Contributor

Reproduced on Windows 10 Chrome stable
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/56.0.2924.87 Safari/537.36"

Reproduced on Windows 10 Firefox stable
"Mozilla/5.0 (Windows NT 10.0; WOW64; rv:51.0) Gecko/20100101 Firefox/51.0"

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

No branches or pull requests

3 participants