summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
Diffstat (limited to 'indra')
-rw-r--r--indra/llui/lltexteditor.cpp24
-rw-r--r--indra/llui/lltexteditor.h8
-rw-r--r--indra/newview/llfloaterimnearbychat.cpp4
3 files changed, 23 insertions, 13 deletions
diff --git a/indra/llui/lltexteditor.cpp b/indra/llui/lltexteditor.cpp
index d297e54f2f..42c5f150dc 100644
--- a/indra/llui/lltexteditor.cpp
+++ b/indra/llui/lltexteditor.cpp
@@ -246,8 +246,8 @@ LLTextEditor::Params::Params()
}
LLTextEditor::LLTextEditor(const LLTextEditor::Params& p) :
- LLTextBase(p),
- mAutoreplaceCallback(),
+ LLTextBase(p),
+ mAutoreplaceCallback(),
mBaseDocIsPristine(TRUE),
mPristineCmd( NULL ),
mLastCmd( NULL ),
@@ -1099,11 +1099,21 @@ void LLTextEditor::addChar(llwchar wc)
setCursorPos(mCursorPos + addChar( mCursorPos, wc ));
- if (!mReadOnly && mAutoreplaceCallback != NULL)
- {
- // call callback
- mAutoreplaceCallback(getViewModel()->getEditableDisplay(), mCursorPos);
- }
+ if (!mReadOnly && mAutoreplaceCallback != NULL)
+ {
+ // autoreplace on a copy of the text (so we can go through proper channels to set it later)
+ LLWString new_text(getWText());
+ S32 new_cursor_pos(mCursorPos);
+ mAutoreplaceCallback(new_text, new_cursor_pos);
+
+ if (new_text != getWText())
+ {
+ // setText() might be simpler here but it wipes the undo stack (bad)
+ remove(0, getWText().length(), true);
+ insert(0, new_text, false, LLTextSegmentPtr());
+ setCursorPos(new_cursor_pos);
+ }
+ }
}
void LLTextEditor::addLineBreakChar()
diff --git a/indra/llui/lltexteditor.h b/indra/llui/lltexteditor.h
index ae5a983b60..7f0dbc9865 100644
--- a/indra/llui/lltexteditor.h
+++ b/indra/llui/lltexteditor.h
@@ -157,10 +157,10 @@ public:
BOOL isPristine() const;
BOOL allowsEmbeddedItems() const { return mAllowEmbeddedItems; }
- // Autoreplace (formerly part of LLLineEditor)
- typedef boost::function<void(LLWString&, S32&)> autoreplace_callback_t;
- autoreplace_callback_t mAutoreplaceCallback;
- void setAutoreplaceCallback(autoreplace_callback_t cb) { mAutoreplaceCallback = cb; }
+ // Autoreplace (formerly part of LLLineEditor)
+ typedef boost::function<void(LLWString&, S32&)> autoreplace_callback_t;
+ autoreplace_callback_t mAutoreplaceCallback;
+ void setAutoreplaceCallback(autoreplace_callback_t cb) { mAutoreplaceCallback = cb; }
//
// Text manipulation
diff --git a/indra/newview/llfloaterimnearbychat.cpp b/indra/newview/llfloaterimnearbychat.cpp
index 73eb822036..38f49e76d4 100644
--- a/indra/newview/llfloaterimnearbychat.cpp
+++ b/indra/newview/llfloaterimnearbychat.cpp
@@ -112,8 +112,8 @@ BOOL LLFloaterIMNearbyChat::postBuild()
{
setIsSingleInstance(TRUE);
BOOL result = LLFloaterIMSessionTab::postBuild();
-
- mInputEditor->setAutoreplaceCallback(boost::bind(&LLAutoReplace::autoreplaceCallback, LLAutoReplace::getInstance(), _1, _2));
+
+ mInputEditor->setAutoreplaceCallback(boost::bind(&LLAutoReplace::autoreplaceCallback, LLAutoReplace::getInstance(), _1, _2));
mInputEditor->setCommitCallback(boost::bind(&LLFloaterIMNearbyChat::onChatBoxCommit, this));
mInputEditor->setKeystrokeCallback(boost::bind(&LLFloaterIMNearbyChat::onChatBoxKeystroke, this));
mInputEditor->setFocusLostCallback(boost::bind(&LLFloaterIMNearbyChat::onChatBoxFocusLost, this));