Commit 7843bf19 authored by Jake Goldsborough's avatar Jake Goldsborough

removing extraneous if. getting updated position of next occurence

parent 707e6f10
......@@ -140,15 +140,14 @@ impl Editor {
/// Get n'th next ocurrence of a given charecter (relatively to the cursor)
pub fn next_ocur(&self, c: char, n: usize) -> Option<usize> {
let mut dn = 0;
let x = self.x();
for ch in self.buffers.current_buffer()[self.y()].chars().skip(x) {
if dn == n {
if ch == c {
dn += 1;
if dn == n {
return Some(x);
}
let mut x = self.x();
for (i, ch) in self.buffers.current_buffer()[self.y()].chars().skip(x).enumerate() {
if ch == c {
dn += 1;
if dn == n {
x += i;
return Some(x);
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment