Skip to content

Commit

Permalink
Fix loop condition in line. Optimize to 1022 LOC. Add TODO
Browse files Browse the repository at this point in the history
  • Loading branch information
mtimaN committed Jan 20, 2024
1 parent be9f447 commit 03b802b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -671,6 +671,7 @@ impl Editor {
let num_rows = self.rows.len();
let mut cur = lst.unwrap_or_else(|| (usize::MAX, num_rows.saturating_sub(1)));
while {

Check warning on line 673 in src/editor.rs

View check run for this annotation

Codecov / codecov/patch

src/editor.rs#L672-L673

Added lines #L672 - L673 were not covered by tests
// TODO: add find backwards on the same line

Check notice

Code scanning / devskim

A "TODO" or similar was left in source code, possibly indicating incomplete functionality Note

Suspicious comment
let row = &mut self.rows[cur.1];
let slice = if cur.0 == usize::MAX { &row.chars[..] } else { &row.chars[cur.0 + 1..] };
if let Some(cx) = slice_find(slice, q.as_bytes()) {
Expand All @@ -679,11 +680,10 @@ impl Editor {
let rx = row.cx2rx[cur.0];
row.match_segment = Some(rx..rx + q.len());
return Some(cur);

Check warning on line 682 in src/editor.rs

View check run for this annotation

Codecov / codecov/patch

src/editor.rs#L675-L682

Added lines #L675 - L682 were not covered by tests
} else {
cur = (usize::MAX, (cur.1 + if fw { 1 } else { num_rows - 1 }) % num_rows);
}
// if it wrapped back to the starting point
cur == lst.unwrap_or_else(|| (usize::MAX, num_rows.saturating_sub(1)))
cur = (usize::MAX, (cur.1 + if fw { 1 } else { num_rows - 1 }) % num_rows);

Check warning on line 684 in src/editor.rs

View check run for this annotation

Codecov / codecov/patch

src/editor.rs#L684

Added line #L684 was not covered by tests
// if it wrapped back to the starting line
cur.1 != lst.map_or(num_rows.saturating_sub(1), |lst| lst.1)

Check warning on line 686 in src/editor.rs

View check run for this annotation

Codecov / codecov/patch

src/editor.rs#L686

Added line #L686 was not covered by tests
} {}
None
}
Expand Down

0 comments on commit 03b802b

Please sign in to comment.