From 955744e5d0b0e2541a2cba4e272edc4ddf60bc09 Mon Sep 17 00:00:00 2001 From: Maxime Coste Date: Fri, 2 Sep 2011 17:07:35 +0000 Subject: [PATCH] prompt: correctly handle backspace when empty --- src/main.cc | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/main.cc b/src/main.cc index b4169139..32870b52 100644 --- a/src/main.cc +++ b/src/main.cc @@ -165,11 +165,14 @@ std::string prompt(const std::string& text) case '\r': return result; case 7: - move(max_y - 1, text.length() + result.length() - 1); - addch(' '); - result.resize(result.length() - 1); - move(max_y - 1, text.length() + result.length()); - refresh; + if (not result.empty()) + { + move(max_y - 1, text.length() + result.length() - 1); + addch(' '); + result.resize(result.length() - 1); + move(max_y - 1, text.length() + result.length()); + refresh(); + } break; case 27: throw prompt_aborted();