diff --git a/src/gui/interface/Textbox.cpp b/src/gui/interface/Textbox.cpp index ddeed791d..41520afa3 100644 --- a/src/gui/interface/Textbox.cpp +++ b/src/gui/interface/Textbox.cpp @@ -358,7 +358,12 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool else if (backingText.length() && cursor < (int)backingText.length()) { if (ctrl) - backingText.erase(cursor, backingText.length()-cursor); + { + size_t stopChar; + stopChar = backingText.find_first_not_of(" .,!?\n", cursor); + stopChar = backingText.find_first_of(" .,!?\n", stopChar); + backingText.erase(cursor, stopChar-cursor); + } else backingText.erase(cursor, 1); changed = true; @@ -380,8 +385,14 @@ void Textbox::OnVKeyPress(int key, Uint16 character, bool shift, bool ctrl, bool { if (ctrl) { - backingText.erase(0, cursor); - cursor = 0; + size_t stopChar; + stopChar = backingText.substr(0, cursor).find_last_not_of(" .,!?\n"); + if (stopChar == backingText.npos) + stopChar = -1; + else + stopChar = backingText.substr(0, stopChar).find_last_of(" .,!?\n"); + backingText.erase(stopChar+1, cursor-(stopChar+1)); + cursor = stopChar+1; } else {