Make trailing line breaks count as lines#21
Open
QnnOkabayashi wants to merge 1 commit intonoib3:mainfrom
Open
Conversation
Owner
|
LGTM (once Clippy passes), but I wouldn't merge it without the corresponding changes to the For example, this test should pass: #[test]
fn lines_iterator_len_mismatch() {
let r = Rope::from("foo\n");
assert_eq!(r.lines().len(), 2);
let mut lines = r.lines();
assert_eq!(lines.next().unwrap(), "foo");
assert_eq!(lines.next().unwrap(), "");
assert_eq!(lines.next(), None);
let mut lines = r.lines();
assert_eq!(lines.next_back().unwrap(), "");
assert_eq!(lines.next_back().unwrap(), "foo");
assert_eq!(lines.next_back(), None);
} |
Contributor
|
Hello 👋 , I would be interested in picking up this issue again if that is okay as it seems to have gone stale. I am also now running into issues with this behavior. |
Owner
|
@kntng I don't have time to work on this myself now, but if you want to pick up this PR (or open a new one), I'd review it. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Related: #20
This makes the concept of "lines" and line counts align with what we would expect when displaying text in a text editor, e.g. the empty string is 1 line, the string
"foo\n"is 2 lines,"foo\nbar"is 2 lines, and so on. The main difference is that trailing newlines now count as another line.