From 6a05496b6f4fcd79f976ae8df75c251bff51914c Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Thu, 10 Mar 2022 13:07:07 +0800 Subject: [PATCH] - fix: calculation for code snippets's tab stop positions is not correct --- NEWS.md | 3 +++ RedPandaIDE/editor.cpp | 26 +++++++++++++++++--------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/NEWS.md b/NEWS.md index df0834f7..eba5b67b 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +Red Panda C++ Version 1.0.0 + - fix: calculation for code snippets's tab stop positions is not correct + Red Panda C++ Version 0.14.5 - fix: the "gnu c++ 20" option in compiler set options is wrong - enhancement: option "open files in the same red panda C++ instance", in options->environment->file associations diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 3f57930b..445980be 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -2611,9 +2611,9 @@ void Editor::insertCodeSnippet(const QString &code) QStringList newSl; for (int i=0;i0) - lastPos = -spaceCount; + QString s = sl[i].trimmed(); +// if (i>0) +// lastPos = -spaceCount; while (true) { int insertPos = s.indexOf(USER_CODE_IN_INSERT_POS); if (insertPos < 0) // no %INSERT% macro in this line now @@ -2629,8 +2629,8 @@ void Editor::insertCodeSnippet(const QString &code) mUserCodeInTabStops.append(p); } lastPos = 0; - if (i>0) - lastPos = -spaceCount; +// if (i>0) +// lastPos = -spaceCount; while (true) { int insertPos = s.indexOf(USER_CODE_IN_REPL_POS_BEGIN); if (insertPos < 0) // no %INSERT% macro in this line now @@ -3608,11 +3608,19 @@ void Editor::popUserCodeInTabStops() PTabStop p = mUserCodeInTabStops.front(); // Update the cursor if (p->y ==0) { - tabStopBegin = mTabStopEnd + p->x; - tabStopEnd = mTabStopEnd + p->endX; + tabStopBegin = mTabStopEnd + p->x; + tabStopEnd = mTabStopEnd + p->endX; } else { - tabStopBegin = p->x+1; - tabStopEnd = p->endX+1; + QString line = lines()->getString(caretY()-1+p->y); + int n=0; + while (n32) + break; + n++; + } +// qDebug()<x; + tabStopBegin = n+p->x+1; + tabStopEnd = n+p->endX+1; } mTabStopY = caretY() + p->y; newCursorPos.Line = mTabStopY;