From eb41965ac33ef4c18cfbca5df6278ea1c7d6a8d8 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Thu, 9 May 2019 21:37:58 +0200 Subject: [PATCH] reader: Remove superfluous while-loop It's possible this was useful at some point, but now it just always inserts the string the first time. --- src/reader.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/src/reader.cpp b/src/reader.cpp index 21c1cc365..e0112c113 100644 --- a/src/reader.cpp +++ b/src/reader.cpp @@ -1127,19 +1127,11 @@ void reader_data_t::remove_backward() { /// using syntax highlighting, etc. /// Returns true if the string changed. bool reader_data_t::insert_string(editable_line_t *el, const wcstring &str) { - size_t len = str.size(); - if (len == 0) return false; + if (str.empty()) return false; - // Start inserting. - size_t cursor = 0; - while (cursor < len) { - // Insert from the cursor up to but not including the range end. - el->insert_string(str, cursor, len - cursor); - - update_buff_pos(el, el->position); - command_line_changed(el); - cursor = len; - } + el->insert_string(str, 0, str.size()); + update_buff_pos(el, el->position); + command_line_changed(el); if (el == &command_line) { suppress_autosuggestion = false;