diff --git a/src/engine.rs b/src/engine.rs index d4956f30..d1bdc303 100644 --- a/src/engine.rs +++ b/src/engine.rs @@ -292,8 +292,7 @@ impl Reedline { } fn insert_char(&mut self, c: char) { - let insertion_point = self.line_buffer.insertion_point(); - self.line_buffer.insert_char_at(insertion_point, c); + self.line_buffer.insert_char(c) } fn backspace(&mut self) { @@ -826,10 +825,7 @@ impl Reedline { }; if self.maybe_wrap(terminal_size.0, line_start, c) { let (original_column, original_row) = position()?; - self.run_edit_commands(&[ - EditCommand::InsertChar(c), - EditCommand::MoveRight, - ]); + self.run_edit_commands(&[EditCommand::InsertChar(c)]); self.buffer_paint(prompt_offset)?; let (new_column, _) = position()?; @@ -844,10 +840,7 @@ impl Reedline { line_count += 1; } } else { - self.run_edit_commands(&[ - EditCommand::InsertChar(c), - EditCommand::MoveRight, - ]); + self.run_edit_commands(&[EditCommand::InsertChar(c)]); } } (KeyModifiers::NONE, KeyCode::Enter, x) if x != EditMode::ViNormal => { diff --git a/src/line_buffer.rs b/src/line_buffer.rs index ec5db07a..e9707909 100644 --- a/src/line_buffer.rs +++ b/src/line_buffer.rs @@ -136,17 +136,13 @@ impl LineBuffer { self.insertion_point.offset } + ///Insert a single character at the insertion point and move right pub fn insert_char(&mut self, c: char) { let pos = self.insertion_point(); self.lines[pos.line].insert(pos.offset, c); self.move_right(); } - /// Insert a single character at the given cursor postion - pub fn insert_char_at(&mut self, pos: InsertionPoint, c: char) { - self.lines[pos.line].insert(pos.offset, c) - } - pub fn insert_str(&mut self, string: &str) { let pos = self.insertion_point(); self.lines[pos.line].insert_str(pos.offset, string);