Skip to content

Commit a7e84c9

Browse files
committed
Restore currently entered text in chat entry textbox after going through history with Ctrl-PgUp/PgDown (#2680)
1 parent c7ebde4 commit a7e84c9

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

indra/llui/llchatentry.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ LLChatEntry::LLChatEntry(const Params& p)
4545
mExpandLinesCount(p.expand_lines_count),
4646
mPrevLinesCount(0),
4747
mSingleLineMode(false),
48-
mPrevExpandedLineCount(S32_MAX)
48+
mPrevExpandedLineCount(S32_MAX),
49+
mCurrentInput("")
4950
{
5051
// Initialize current history line iterator
5152
mCurrentHistoryLine = mLineHistory.begin();
@@ -189,13 +190,19 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
189190
{
190191
needsReflow();
191192
}
193+
mCurrentInput = "";
192194
break;
193195

194196
case KEY_UP:
195197
if (mHasHistory && MASK_CONTROL == mask)
196198
{
197199
if (!mLineHistory.empty() && mCurrentHistoryLine > mLineHistory.begin())
198200
{
201+
if (mCurrentHistoryLine == mLineHistory.end())
202+
{
203+
mCurrentInput = getText();
204+
}
205+
199206
setText(*(--mCurrentHistoryLine));
200207
endOfDoc();
201208
}
@@ -210,16 +217,15 @@ bool LLChatEntry::handleSpecialKey(const KEY key, const MASK mask)
210217
case KEY_DOWN:
211218
if (mHasHistory && MASK_CONTROL == mask)
212219
{
213-
if (!mLineHistory.empty() && mCurrentHistoryLine < (mLineHistory.end() - 1) )
220+
if (!mLineHistory.empty() && mCurrentHistoryLine < (mLineHistory.end() - 1))
214221
{
215222
setText(*(++mCurrentHistoryLine));
216223
endOfDoc();
217224
}
218-
else if (!mLineHistory.empty() && mCurrentHistoryLine == (mLineHistory.end() - 1) )
225+
else if (!mLineHistory.empty() && mCurrentHistoryLine == (mLineHistory.end() - 1))
219226
{
220227
mCurrentHistoryLine++;
221-
std::string empty("");
222-
setText(empty);
228+
setText(mCurrentInput);
223229
needsReflow();
224230
endOfDoc();
225231
}

indra/llui/llchatentry.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ class LLChatEntry : public LLTextEditor
101101
S32 mExpandLinesCount;
102102
S32 mPrevLinesCount;
103103
S32 mPrevExpandedLineCount;
104+
105+
std::string mCurrentInput;
104106
};
105107

106108
#endif /* LLCHATENTRY_H_ */

0 commit comments

Comments
 (0)