From 96fc4c03632a54401b90eec809c1595fc611c7ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kacper=20Macio=C5=82ek?= Date: Mon, 17 Jun 2024 22:34:00 +0200 Subject: [PATCH] gap buffer p8 --- src/app.rs | 1 - src/gap_buffer.rs | 10 ++++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/app.rs b/src/app.rs index 4d87cc1..3950566 100644 --- a/src/app.rs +++ b/src/app.rs @@ -189,7 +189,6 @@ impl App { let current_line = &mut self.content[self.cursor_position.y]; if current_line.len() > pos.x { - // TODO: fix let new_line = current_line.split_off(pos.x); self.insert_to_content(pos.y + 1, new_line); diff --git a/src/gap_buffer.rs b/src/gap_buffer.rs index 8e620e7..e0e1dbb 100644 --- a/src/gap_buffer.rs +++ b/src/gap_buffer.rs @@ -101,14 +101,12 @@ impl GapBuffer { new_buffer[..new_capacity].copy_from_slice(&self.buffer[self.gap_end..]); - let split_buffer = GapBuffer { + self.gap_end = self.buffer.len(); + + GapBuffer { buffer: new_buffer, gap_start: 0, gap_end: new_capacity, - }; - - self.gap_end = self.buffer.len(); - - split_buffer + } } }