Commit e91cc892 authored by Ticki's avatar Ticki

Fix bug in d<motion> command

parent f0d6d5e6
......@@ -5,7 +5,7 @@
Known bugs:
- [x] When using `t` with a char that isn't in the document, Sodium will crash.
- [ ] `d<motion>` does not do anything if: 1) the motion moves to the end of a line. 2) if the motion moves to the last line.
- [x] `d<motion>` does not do anything if: 1) the motion moves to the end of a line. 2) if the motion moves to the last line.
The bug causing these two bugs, is localised to be in position.rs. It resolves by returning a value one over bound x
......
......@@ -113,7 +113,7 @@ impl Editor {
},
Char('d') => {
let ins = self.next_inst();
if let Some(m) = self.to_motion(ins) {
if let Some(m) = self.to_motion_unbounded(ins) {
debugln!("Delete (x, y) : ({}, {})", m.0, m.1);
self.remove_rb(m);
}
......
......@@ -3,9 +3,10 @@ use redox::*;
impl Editor {
/// Remove from a given motion (row based)
pub fn remove_rb<'a>(&mut self, (x, y): (usize, usize)) {
pub fn remove_rb<'a>(&mut self, (x, y): (isize, isize)) {
debugln!("Y: {}, Bounded y: {}", y, self.y());
if y == self.y() {
if y == self.y() as isize {
let (x, y) = self.bound((x as usize, y as usize));
// Single line mode
let (a, b) = if self.x() > x {
(x, self.x())
......@@ -17,6 +18,7 @@ impl Editor {
self.text[y].remove(a);
}
} else {
let (x, y) = self.bound((x as usize, y as usize));
debugln!("Full line mode!");
// Full line mode
let (a, b) = if self.y() < y {
......
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