Skip to content

Commit

Permalink
Replace use of insert_str_at with insert_str
Browse files Browse the repository at this point in the history
  • Loading branch information
nixypanda committed Jun 21, 2021
1 parent f1ffa23 commit 10b4ea0
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,11 +392,8 @@ impl Reedline {
}

fn insert_cut_buffer(&mut self) {
let insertion_offset = self.insertion_point().offset;
let cut_buffer = self.cut_buffer.get();
self.line_buffer
.insert_str_at(self.insertion_point(), &cut_buffer);
self.set_insertion_point(insertion_offset + cut_buffer.len());
self.line_buffer.insert_str(&cut_buffer);
}

fn uppercase_word(&mut self) {
Expand Down
10 changes: 3 additions & 7 deletions src/line_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,19 +143,15 @@ impl LineBuffer {
self.move_right();
}

/// Insert `&str` at the `idx` position in the current line.
///
/// TODO: Check unicode validation
pub fn insert_str(&mut self, string: &str) {
let pos = self.insertion_point();
self.lines[pos.line].insert_str(pos.offset, string);
self.insertion_point.offset = pos.offset + string.len();
}

/// Insert `&str` at the `idx` position in the current line.
///
/// TODO: Check unicode validation
pub fn insert_str_at(&mut self, pos: InsertionPoint, string: &str) {
self.lines[pos.line].insert_str(pos.offset, string)
}

/// Empty buffer and reset cursor
pub fn clear(&mut self) {
self.lines.clear();
Expand Down

0 comments on commit 10b4ea0

Please sign in to comment.