Tweak removeWord code to make it work for text editors and make more sense

This commit is contained in:
Inusaito Sayori
2015-07-17 22:07:35 -04:00
parent 3d1d138074
commit 0b70603a0c
2 changed files with 13 additions and 17 deletions

View File

@@ -867,10 +867,10 @@ void LLLineEditor::removeChar()
// Remove a word (set of characters up to next space/punctuation) from the text
void LLLineEditor::removeWord(bool prev)
{
const U32 pos(getCursor());
if (prev ? pos > 0 : static_cast<S32>(pos) < getLength())
const S32& pos(mCursorPos);
if (prev ? pos > 0 : pos < getLength())
{
U32 new_pos(prev ? prevWordPos(pos) : nextWordPos(pos));
S32 new_pos(prev ? prevWordPos(pos) : nextWordPos(pos));
if (new_pos == pos) // Other character we don't jump over
new_pos = prev ? prevWordPos(new_pos-1) : nextWordPos(new_pos+1);