From: Francois Fleuret Date: Mon, 6 Apr 2009 19:31:43 +0000 (+0200) Subject: Removed a bug when inserting a char in the middle of the pattern. X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=9ac8b5e29aa7d08129e37cd21fea844ba916f64d;p=selector.git Removed a bug when inserting a char in the middle of the pattern. --- diff --git a/selector.cc b/selector.cc index b84bd79..c936029 100644 --- a/selector.cc +++ b/selector.cc @@ -755,18 +755,15 @@ int main(int argc, char **argv) { if(key >= ' ' && key <= '~') { // Insert character int c = cursor_position; char t = pattern[c], u; - if(t) { - while(t) { - c++; - u = pattern[c]; - pattern[c] = t; - t = u; - } - pattern[cursor_position++] = key; - } else { - pattern[cursor_position++] = key; - pattern[cursor_position] = '\0'; + while(t) { + c++; + u = pattern[c]; + pattern[c] = t; + t = u; } + c++; + pattern[c] = '\0'; + pattern[cursor_position++] = key; } else if(key == KEY_BACKSPACE || key == '' || key == '') {