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

Wrong line numbers #1643

Closed
antoyo opened this issue Feb 10, 2022 · 9 comments
Closed

Wrong line numbers #1643

antoyo opened this issue Feb 10, 2022 · 9 comments
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug upstream

Comments

@antoyo
Copy link
Contributor

antoyo commented Feb 10, 2022

When opening this file, I have the wrong line numbers.

Reproduction steps

Open the above file and type 11081G and you'll end up on line 11063 even though it shows 11081 in helix.

Environment

  • Platform: Linux
  • Terminal emulator: Alacritty
  • Helix version: helix v0.6.0
@antoyo antoyo added the C-bug Category: This is a bug label Feb 10, 2022
@tomKPZ
Copy link
Contributor

tomKPZ commented Feb 10, 2022

Looks like the first inconsistency is around the 2 blank lines L104-L105 which helix renders as 3 empty lines. If I press j/k repeatedly around those lines, I can get the editor to hang.

@tomKPZ
Copy link
Contributor

tomKPZ commented Feb 10, 2022

The bytes for those lines are 0a 0a 0c 0a, so 3 newlines and a form feed.

@kirawi kirawi added the A-helix-term Area: Helix term improvements label Feb 11, 2022
@kirawi
Copy link
Member

kirawi commented Feb 11, 2022

@cessen Do you have an idea of what could be happening here?

@kirawi
Copy link
Member

kirawi commented Feb 12, 2022

Can you compare to what other editors report?

@cessen
Copy link
Contributor

cessen commented Feb 12, 2022

Looks like the first inconsistency is around the 2 blank lines L104-L105 which helix renders as 3 empty lines.

I think Helix is actually rendering this correctly...? The form feed character (0x0c) is an explicit page break, which implies a line break as well. So the sequence 0a 0a 0c 0a is a series of four line breaks (one of which also happens to be a page break), resulting in three blank lines.

Having said that, none of the other editors I've opened this file with (emacs, vim, sublime) render it that way. So it's possible I misinterpreted the Unicode spec when implementing line breaks in Ropey. But it seems pretty clear to me (under the "mandatory break" section):

FORM FEED separates pages. The text on the new page starts at the beginning of the line. In some layout modes there may be no visible advance to a new “page”.

@archseer
Copy link
Member

I think the problem is that very few editors actually conform to the spec and only accept CR/CRLF (an example being the LSP spec only treating those two as line endings as well).

Ropey is more correct here, but it might be nice to put the additional line endings under a feature flag. That way we could only treat CR/CRLF as line endings, then render the others with a special mark to indicate them -- if I'm editing code then I don't really expect any other line endings, and if they do appear it's usually a bug.

@antoyo
Copy link
Contributor Author

antoyo commented Feb 12, 2022

The thing is: a failed assertion in GCC will output the line number and if I want to go to this line number easily, and helix print the line numbers correctly while every other piece of software is wrong, it makes it harder to go to this line number.

@cessen
Copy link
Contributor

cessen commented Feb 12, 2022

but it might be nice to put the additional line endings under a feature flag. That way we could only treat CR/CRLF as line endings, then render the others with a special mark to indicate them

That's a great idea. I'll put that on my to-do list for Ropey. I'll also happily accept a PR if someone else gets to it first. I believe it would just involve making alternative versions of the line-related str_utils functions.

@cessen
Copy link
Contributor

cessen commented Feb 12, 2022

I've made an issue on the Ropey repo for this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-helix-term Area: Helix term improvements C-bug Category: This is a bug upstream
Projects
None yet
Development

No branches or pull requests

5 participants