From 9ac8b5e29aa7d08129e37cd21fea844ba916f64d Mon Sep 17 00:00:00 2001 From: Francois Fleuret Date: Mon, 6 Apr 2009 21:31:43 +0200 Subject: [PATCH] Removed a bug when inserting a char in the middle of the pattern. --- selector.cc | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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 == '') { -- 2.39.5