diff options
| author | Irene Knapp <ireneista@irenes.space> | 2026-03-27 06:53:51 -0700 |
|---|---|---|
| committer | Irene Knapp <ireneista@irenes.space> | 2026-03-27 06:53:51 -0700 |
| commit | a15c23a885a8ff53e9bcd20c96b8a3813a08e19e (patch) | |
| tree | f68f7c28b7c2162a56ef70da2634365b4363b0c7 /src/main.rs | |
| parent | a801a36a5acc8adb43ea308c09e759a2f1c2344c (diff) | |
count_lines() wasn't handling empty lines properly
remember, they can occur in the middle, not just at the end! heh Force-Push: yes Change-Id: I52d2c29e40597c0bfc9484fec5cef7f13612cb19
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/main.rs b/src/main.rs index 79abbd5..5929295 100644 --- a/src/main.rs +++ b/src/main.rs @@ -347,19 +347,17 @@ impl Buffer { while offset < contents.len() { let c = contents[offset]; - if c == b'\n' { - offset += 1; + offset += 1; + if c == b'\n' { if offset < contents.len() { self.lines.write().await.push(offset); } else { *self.has_end_newline.write().await = true; } - } else if offset + 1 == contents.len() { + } else if offset == contents.len() { *self.has_end_newline.write().await = false; } - - offset += 1; } } } |