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

Inconsistent behavior between Line::from and Line::raw #1111

Open
kdheepak opened this issue May 15, 2024 · 3 comments
Open

Inconsistent behavior between Line::from and Line::raw #1111

kdheepak opened this issue May 15, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@kdheepak
Copy link
Collaborator

Description

Line::from doesn't split the spans on new lines:

let line = Line::from("hello world\ngoodbye world");
dbg!(line.spans.len()) // 1

let line = Line::raw("hello world\ngoodbye world");
dbg!(line.spans.len()) // 2
@kdheepak kdheepak added the bug Something isn't working label May 15, 2024
@EdJoPaTo
Copy link
Member

The idea of line is to have no new lines. So… not sure which is the more correct behaviour?

@kdheepak
Copy link
Collaborator Author

I would expect this to be correct behaviour:

let line = Line::raw("hello world\ngoodbye world");
dbg!(line.spans.len()) // 2

precisely because of the reason you've stated: Line shouldn't have newlines.

@joshka
Copy link
Member

joshka commented May 15, 2024

Two spans makes it possible to use &strs, one span would mean that an owned string would have to be constructed from the two lines. I think we currently just filter out the newlines when displaying the spans, so the behavior probably just works alright as-is, but going to two makes sense.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants