fix bad line in write command

This commit is contained in:
rick 2023-04-23 19:16:47 +02:00
parent f0f059ea32
commit 4a583272d6
Signed by: Rick
GPG key ID: 5CBE8779CD27BCBA

View file

@ -6,6 +6,8 @@ use std::io::Write;
pub struct Buffer {
has_changed: bool,
buffer: Vec<Result<String, io::Error>>,
// vraie adresse dans le vecteur, l'utilisateur se trouve à current_line +
// 1 pour lui.
current_line: usize,
file_name: String,
}
@ -38,9 +40,9 @@ impl Buffer {
pub fn save(&mut self, range: Address) {
let len = self.buffer.len();
let curr = self.current_line.saturating_sub(1);
let curr = self.current_line;
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::Last => self.save_range(len.saturating_sub(1), len),
Address::Line(l) => self.save_range(l.saturating_sub(1), l),