Commit 1ce9eb2d authored by Jeremy Soller's avatar Jeremy Soller

Merge branch 'master' of https://github.com/redox-os/sodium

parents bb398aee 5e50c9d9
......@@ -54,10 +54,10 @@ NOTE: <numeral> means repeat command
stated.
Basic motion:
- <numeral>h : Go right
- <numeral>h : Go left
- <numeral>j : Go down
- <numeral>k : Go up
- <numeral>l : Go left
- <numeral>l : Go right
- <numeral>J : Go 15 down
- <numeral>K : Go 15 up
- <numeral>H : Go to the start of
......
......@@ -140,13 +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();
let mut x = self.x();
for ch in self.buffers.current_buffer()[self.y()].chars().skip(x) {
if dn == n {
if ch == c {
for (i, ch) in self.buffers.current_buffer()[self.y()].chars().skip(x).enumerate() {
if ch == c {
if i > 0 {
dn += 1;
if dn == n {
x += i;
return Some(x);
}
}
......@@ -159,16 +160,15 @@ impl Editor {
/// Get n'th previous ocurrence of a given charecter (relatively to the cursor)
pub fn previous_ocur(&self, c: char, n: usize) -> Option<usize> {
let mut dn = 0;
let x = self.x();
let mut x = self.x();
let y = self.y();
for ch in self.buffers.current_buffer()[y].chars().rev().skip(self.buffers.current_buffer()[y].len() - x) {
if dn == n {
if ch == c {
dn += 1;
if dn == n {
return Some(x);
}
for (i, ch) in self.buffers.current_buffer()[y].chars().rev().skip(self.buffers.current_buffer()[y].len() - x).enumerate() {
if ch == c {
dn += 1;
if dn == n {
x -= i + 1;
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