Commit 94814d10 authored by Ticki's avatar Ticki

Brutally kill some errors introduced in the last commit

parent 2ef6b303
......@@ -162,7 +162,7 @@ pub trait Buffer<'a> {
fn remove_line(&mut self, n: usize) -> Self::Line;
/// Insert line at n. Panics on out of bound.
fn insert_line(&mut self, n: usize, line: Self::Line);
fn insert_line(&mut self, n: usize, line: &<Self::Line as Line<'a>>::Slice);
/// Convert a vector of lines to a split buffer
fn from_lines(vec: &[Self::Line]) -> SplitBuffer;
......@@ -295,12 +295,12 @@ impl<'a> Buffer<'a> for SplitBuffer {
}
/// Insert line at n. Panics on out of bound.
fn insert_line(&mut self, n: usize, line: String) {
fn insert_line(&mut self, n: usize, line: &str) {
if n < self.before.len() {
self.before.insert(n, line);
self.before.insert(n, line.into());
} else if n < self.len() {
let n = self.len() - 1 - n;
self.after.insert(n, line);
self.after.insert(n, line.into());
} else {
panic!("Out of bound");
}
......@@ -364,7 +364,7 @@ impl<'a> Buffer<'a> for SplitBuffer {
}.to_string();
let begin = nl.len();
self.insert_line(y, nl + &second_part);
self.insert_line(y, &(nl + &second_part));
begin
}
......
......@@ -11,7 +11,7 @@ use std::iter::FromIterator;
// TODO: Move the command definitions outta here
impl<'a, B: Buffer<'a>> Editor<B> {
/// Execute an instruction
pub fn exec(&mut self, Inst(para, cmd): Inst) {
pub fn exec(&'a mut self, Inst(para, cmd): Inst) {
use key::Key::*;
use mode::Mode::*;
use mode::PrimitiveMode::*;
......@@ -74,14 +74,13 @@ impl<'a, B: Buffer<'a>> Editor<B> {
}
Char('o') => {
let y = self.y();
let ln = self.buffer.get_line(y);
let ind = if self.options.autoindent {
ln.get_indent()
self.buffer.get_line(y).get_indent()
} else {
<B::Line as Line>::Slice::new_empty()
};
let last = ind.len();
self.buffer.insert_line(y, <B::Line as Line<'a>>::from_slice(ind));
self.buffer.insert_line(y, ind);
self.goto((last, y + 1));
self.cursor_mut().mode =
Mode::Primitive(PrimitiveMode::Insert(InsertOptions {
......
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