From 024032c6745300a0cde75ad404e73a7ddff61534 Mon Sep 17 00:00:00 2001
From: Andrey Kleshchev <andreykproductengine@lindenlab.com>
Date: Fri, 4 Jun 2021 22:31:20 +0300
Subject: SL-15346 "Listing ID" field has OS-dependent length restriction

---
 indra/llui/lllineeditor.cpp                             | 17 +++++++++++++++--
 indra/llui/lllineeditor.h                               |  2 ++
 .../skins/default/xui/en/floater_associate_listing.xml  |  3 ++-
 3 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/indra/llui/lllineeditor.cpp b/indra/llui/lllineeditor.cpp
index 1badd54fca..a88a191847 100644
--- a/indra/llui/lllineeditor.cpp
+++ b/indra/llui/lllineeditor.cpp
@@ -175,6 +175,14 @@ LLLineEditor::LLLineEditor(const LLLineEditor::Params& p)
 	mTripleClickTimer.reset();
 	setText(p.default_text());
 
+    if (p.initial_value.isProvided()
+        && !p.control_name.isProvided())
+    {
+        // Initial value often is descriptive, like "Type some ID here"
+        // and can be longer than size limitation, ignore size
+        setText(p.initial_value.getValue().asString(), true);
+    }
+
 	// Initialize current history line iterator
 	mCurrentHistoryLine = mLineHistory.begin();
 
@@ -389,6 +397,11 @@ void LLLineEditor::updateTextPadding()
 
 
 void LLLineEditor::setText(const LLStringExplicit &new_text)
+{
+    setText(new_text, false);
+}
+
+void LLLineEditor::setText(const LLStringExplicit &new_text, bool ignore_size_limit)
 {
 	// If new text is identical, don't copy and don't move insertion point
 	if (mText.getString() == new_text)
@@ -407,13 +420,13 @@ void LLLineEditor::setText(const LLStringExplicit &new_text)
 	all_selected = all_selected || (len == 0 && hasFocus() && mSelectAllonFocusReceived);
 
 	std::string truncated_utf8 = new_text;
-	if (truncated_utf8.size() > (U32)mMaxLengthBytes)
+	if (!ignore_size_limit && truncated_utf8.size() > (U32)mMaxLengthBytes)
 	{	
 		truncated_utf8 = utf8str_truncate(new_text, mMaxLengthBytes);
 	}
 	mText.assign(truncated_utf8);
 
-	if (mMaxLengthChars)
+	if (!ignore_size_limit && mMaxLengthChars)
 	{
 		mText.assign(utf8str_symbol_truncate(truncated_utf8, mMaxLengthChars));
 	}
diff --git a/indra/llui/lllineeditor.h b/indra/llui/lllineeditor.h
index aa5779d45f..088578a821 100644
--- a/indra/llui/lllineeditor.h
+++ b/indra/llui/lllineeditor.h
@@ -317,6 +317,8 @@ private:
 	virtual S32		getPreeditFontSize() const;
 	virtual LLWString getPreeditString() const { return getWText(); }
 
+    void			setText(const LLStringExplicit &new_text, bool ignore_size_limit);
+
 	void			setContextMenu(LLContextMenu* new_context_menu);
 
 protected:
diff --git a/indra/newview/skins/default/xui/en/floater_associate_listing.xml b/indra/newview/skins/default/xui/en/floater_associate_listing.xml
index e019ed58dd..0f7ed24103 100644
--- a/indra/newview/skins/default/xui/en/floater_associate_listing.xml
+++ b/indra/newview/skins/default/xui/en/floater_associate_listing.xml
@@ -20,9 +20,10 @@
      name="message">
         Listing ID:
     </text>
+    <!--listing_id is a positive S32-->
     <line_editor
      type="string"
-     length="1"
+     max_length_bytes="10"
      follows="top|right"
      font="SansSerif"
      height="20"
-- 
cgit v1.2.3