summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDarl <me@darl.cat>2025-12-31 09:22:35 -0600
committerGitHub <noreply@github.com>2025-12-31 17:22:35 +0200
commit732b96958f0677674ca2756ce6a692f54bfd6a28 (patch)
tree3e954fc3fe759ba0f066006f6151b33fc4a89b1b
parentf27b86c8fac5c1a9db93cd05aaf7480162006951 (diff)
Update LLScriptEditor and friends to index line numbers from 1 when editing in Lua (#5190)
* Update LLScriptEditor to index line numbers from 1 when editing in Lua This is to match server-generated runtime errors that reference lines. Signed-off-by: Darl <me@darl.cat> * Update LLFloaterGotoLine and LLPreviewScript to support Lua's line/col expectations Existing behavior for LSL is preserved Fixes a bug in previous commit that causes the line number shown near the bottom of the script edit floater to be off by 1 when displaying a Lua script. Signed-off-by: Darl <me@darl.cat> * Update script editor error console goto error to reflect Lua line nums Signed-off-by: Darl <me@darl.cat> --------- Signed-off-by: Darl <me@darl.cat>
-rw-r--r--indra/newview/llfloatergotoline.cpp8
-rw-r--r--indra/newview/llpreviewscript.cpp3
-rw-r--r--indra/newview/llscripteditor.cpp2
3 files changed, 9 insertions, 4 deletions
diff --git a/indra/newview/llfloatergotoline.cpp b/indra/newview/llfloatergotoline.cpp
index 09ca0ab530..6b3f16ecf5 100644
--- a/indra/newview/llfloatergotoline.cpp
+++ b/indra/newview/llfloatergotoline.cpp
@@ -109,8 +109,9 @@ void LLFloaterGotoLine::handleBtnGoto()
{
if (mEditorCore && mEditorCore->mEditor)
{
+ S32 target_row = mEditorCore->mEditor->getIsLuauLanguage() ? (row - 1) : row;
mEditorCore->mEditor->deselect();
- mEditorCore->mEditor->setCursor(row, column);
+ mEditorCore->mEditor->setCursor(target_row, column);
mEditorCore->mEditor->setFocus(true);
}
}
@@ -144,12 +145,13 @@ void LLFloaterGotoLine::onGotoBoxCommit()
{
if (mEditorCore && mEditorCore->mEditor)
{
- mEditorCore->mEditor->setCursor(row, column);
+ S32 target_row = mEditorCore->mEditor->getIsLuauLanguage() ? (row - 1) : row;
+ mEditorCore->mEditor->setCursor(target_row, column);
S32 rownew = 0;
S32 columnnew = 0;
mEditorCore->mEditor->getCurrentLineAndColumn( &rownew, &columnnew, false ); // don't include wordwrap
- if (rownew == row && columnnew == column)
+ if (rownew == target_row && columnnew == column)
{
mEditorCore->mEditor->deselect();
mEditorCore->mEditor->setFocus(true);
diff --git a/indra/newview/llpreviewscript.cpp b/indra/newview/llpreviewscript.cpp
index b3e53df6d8..01167a43b8 100644
--- a/indra/newview/llpreviewscript.cpp
+++ b/indra/newview/llpreviewscript.cpp
@@ -751,6 +751,8 @@ void LLScriptEdCore::draw()
S32 line = 0;
S32 column = 0;
mEditor->getCurrentLineAndColumn( &line, &column, false ); // don't include wordwrap
+ line = mEditor->getIsLuauLanguage() ? (line + 1) : line;
+ column = mEditor->getIsLuauLanguage() ? (column + 1) : column;
LLStringUtil::format_map_t args;
std::string cursor_pos;
args["[LINE]"] = llformat ("%d", line);
@@ -1211,6 +1213,7 @@ void LLScriptEdCore::onErrorList(LLUICtrl*, void* user_data)
sscanf(line.c_str(), "%d %d", &row, &column);
//LL_INFOS() << "LLScriptEdCore::onErrorList() - " << row << ", "
//<< column << LL_ENDL;
+ row = (self->mEditor->getIsLuauLanguage() ? row - 1 : row);
self->mEditor->setCursor(row, column);
self->mEditor->setFocus(true);
}
diff --git a/indra/newview/llscripteditor.cpp b/indra/newview/llscripteditor.cpp
index 2a9dd73936..d171d785a7 100644
--- a/indra/newview/llscripteditor.cpp
+++ b/indra/newview/llscripteditor.cpp
@@ -120,7 +120,7 @@ void LLScriptEditor::drawLineNumbers()
// draw the line numbers
if(line.mLineNum != last_line_num && line.mRect.mTop <= scrolled_view_rect.mTop)
{
- const LLWString ltext = utf8str_to_wstring(llformat("%d", line.mLineNum ));
+ const LLWString ltext = utf8str_to_wstring(llformat("%d", mLuauLanguage ? line.mLineNum + 1 : line.mLineNum));
bool is_cur_line = cursor_line == line.mLineNum;
const U8 style = is_cur_line ? LLFontGL::BOLD : LLFontGL::NORMAL;
const LLColor4& fg_color = is_cur_line ? mCursorColor : mReadOnlyFgColor;