fix bad line in write command
This commit is contained in:
parent
f0f059ea32
commit
4a583272d6
1 changed files with 4 additions and 2 deletions
|
@ -6,6 +6,8 @@ use std::io::Write;
|
||||||
pub struct Buffer {
|
pub struct Buffer {
|
||||||
has_changed: bool,
|
has_changed: bool,
|
||||||
buffer: Vec<Result<String, io::Error>>,
|
buffer: Vec<Result<String, io::Error>>,
|
||||||
|
// vraie adresse dans le vecteur, l'utilisateur se trouve à current_line +
|
||||||
|
// 1 pour lui.
|
||||||
current_line: usize,
|
current_line: usize,
|
||||||
file_name: String,
|
file_name: String,
|
||||||
}
|
}
|
||||||
|
@ -38,9 +40,9 @@ impl Buffer {
|
||||||
|
|
||||||
pub fn save(&mut self, range: Address) {
|
pub fn save(&mut self, range: Address) {
|
||||||
let len = self.buffer.len();
|
let len = self.buffer.len();
|
||||||
let curr = self.current_line.saturating_sub(1);
|
let curr = self.current_line;
|
||||||
match range {
|
match range {
|
||||||
Address::Actual => self.save_range(curr, curr),
|
Address::Actual => self.save_range(curr, curr.saturating_add(1)),
|
||||||
Address::Empty | Address::All => self.save_range(0, len),
|
Address::Empty | Address::All => self.save_range(0, len),
|
||||||
Address::Last => self.save_range(len.saturating_sub(1), len),
|
Address::Last => self.save_range(len.saturating_sub(1), len),
|
||||||
Address::Line(l) => self.save_range(l.saturating_sub(1), l),
|
Address::Line(l) => self.save_range(l.saturating_sub(1), l),
|
||||||
|
|
Loading…
Reference in a new issue