From 7c17c987cbdecb5b384211d3e83ffea0a433beca Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Sat, 2 Oct 2021 02:38:12 -0300 Subject: [PATCH] Keep watch list selection across edits (same session) --- source/ide/ide_global.bas | 2 +- source/ide/ide_methods.bas | 17 ++++++++++++++++- source/qb64.bas | 22 +++++++++++++++++++++- 3 files changed, 38 insertions(+), 3 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index f0cd63c55..6ff446348 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -11,7 +11,7 @@ DIM SHARED IDEBuildModeChanged DIM SHARED IdeInfo AS STRING DIM SHARED IdeContextHelpSF AS _BYTE -DIM SHARED host&, debugClient&, hostport$, variableWatchList$, watchpointList$ +DIM SHARED host&, debugClient&, hostport$, variableWatchList$, backupVariableWatchList$, watchpointList$ DIM SHARED vWatchReceivedData$(1 TO 1000), nextvWatchDataSlot, latestWatchpointMet& DIM SHARED startPausedPending AS _BYTE diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 2d6ead084..eab007599 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -509,6 +509,7 @@ FUNCTION ide2 (ignore) REDIM IdeBreakpoints(iden) AS _BYTE REDIM IdeSkipLines(iden) AS _BYTE variableWatchList$ = "" + backupVariableWatchList$ = "": REDIM backupUsedVariableList(1000) AS usedVarList watchpointList$ = "" callstacklist$ = "": callStackLength = 0 ideunsaved = -1 @@ -606,6 +607,7 @@ FUNCTION ide2 (ignore) REDIM IdeBreakpoints(iden) AS _BYTE REDIM IdeSkipLines(iden) AS _BYTE variableWatchList$ = "" + backupVariableWatchList$ = "": REDIM backupUsedVariableList(1000) AS usedVarList watchpointList$ = "" callstacklist$ = "": callStackLength = 0 IF ideStartAtLine > 0 AND ideStartAtLine <= iden THEN @@ -1164,7 +1166,6 @@ FUNCTION ide2 (ignore) IF idelayoutallow THEN idelayoutallow = idelayoutallow - 1 - variableWatchList$ = "" watchpointList$ = "" idecurrentlinelayouti = 0 'invalidate idefocusline = 0 @@ -8682,11 +8683,24 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction) IF K$ = CHR$(27) OR (IdeDebugMode = 0 AND focus = 5 AND info <> 0) OR _ (IdeDebugMode > 0 AND focus = 7 AND info <> 0) THEN variableWatchList$ = "" + backupVariableWatchList$ = "" 'used in case this program is edited in the same session longestVarName = 0 nextvWatchDataSlot = 0 totalVisibleVariables = 0 + totalSelectedVariables = 0 FOR y = 1 TO totalVariablesCreated IF usedVariableList(y).includedLine THEN _CONTINUE 'don't deal with variables in $INCLUDEs + + totalSelectedVariables = totalSelectedVariables + 1 + backupVariableWatchList$ = backupVariableWatchList$ + MKL$(-1) + backupVariableWatchList$ = backupVariableWatchList$ + MKL$(LEN(usedVariableList(y).cname)) + usedVariableList(y).cname + backupVariableWatchList$ = backupVariableWatchList$ + MKL$(totalSelectedVariables) + WHILE totalSelectedVariables > UBOUND(backupUsedVariableList) + REDIM _PRESERVE backupUsedVariableList(totalSelectedVariables + 999) AS usedVarList + WEND + backupUsedVariableList(totalSelectedVariables) = usedVariableList(y) + + usedVariableList(y).storage = "" IF usedVariableList(y).watch THEN thisLen = LEN(usedVariableList(y).name) IF usedVariableList(y).isarray THEN @@ -11913,6 +11927,7 @@ FUNCTION idefiledialog$(programname$, mode AS _BYTE) REDIM IdeBreakpoints(iden) AS _BYTE REDIM IdeSkipLines(iden) AS _BYTE variableWatchList$ = "" + backupVariableWatchList$ = "": REDIM backupUsedVariableList(1000) AS usedVarList callstacklist$ = "": callStackLength = 0 ideerror = 1 diff --git a/source/qb64.bas b/source/qb64.bas index 46f8835c7..8e3c75015 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -120,6 +120,7 @@ TYPE usedVarList AS STRING elementOffset, storage END TYPE +REDIM SHARED backupUsedVariableList(1000) AS usedVarList DIM SHARED totalVariablesCreated AS LONG, totalMainVariablesCreated AS LONG DIM SHARED bypassNextVariable AS _BYTE DIM SHARED totalWarnings AS LONG, warningListItems AS LONG, lastWarningHeader AS STRING @@ -26076,7 +26077,7 @@ SUB dump_udts END SUB SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) - DIM findItem AS LONG, cname$, i AS LONG, name$ + DIM findItem AS LONG, cname$, i AS LONG, j AS LONG, name$, temp$ name$ = RTRIM$(__name$) cname$ = RTRIM$(__cname$) @@ -26098,6 +26099,7 @@ SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) IF i > UBOUND(usedVariableList) THEN REDIM _PRESERVE usedVariableList(UBOUND(usedVariableList) + 999) AS usedVarList END IF + usedVariableList(i).id = currentid usedVariableList(i).used = 0 usedVariableList(i).watch = 0 @@ -26127,9 +26129,12 @@ SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) IF LEN(RTRIM$(id.musthave)) > 0 THEN usedVariableList(i).name = name$ + RTRIM$(id.musthave) + ELSEIF LEN(RTRIM$(id.mayhave)) > 0 THEN + usedVariableList(i).name = name$ + RTRIM$(id.mayhave) ELSE usedVariableList(i).name = name$ END IF + IF (id.arrayelements > 0) THEN usedVariableList(i).isarray = -1 usedVariableList(i).name = usedVariableList(i).name + "()" @@ -26143,6 +26148,21 @@ SUB manageVariableList (__name$, __cname$, localIndex AS LONG, action AS _BYTE) usedVariableList(i).elementTypes = "" usedVariableList(i).elementOffset = "" totalVariablesCreated = totalVariablesCreated + 1 + + temp$ = MKL$(-1) + MKL$(LEN(cname$)) + cname$ + found = INSTR(backupVariableWatchList$, temp$) + IF found THEN + 'this variable existed in a previous edit of this program + 'in this same session; let's preselect it. + j = CVL(MID$(backupVariableWatchList$, found + LEN(temp$), 4)) + usedVariableList(i).watch = backupUsedVariableList(j).watch + usedVariableList(i).watchRange = backupUsedVariableList(j).watchRange + usedVariableList(i).indexes = backupUsedVariableList(j).indexes + usedVariableList(i).elements = backupUsedVariableList(j).elements + usedVariableList(i).elementTypes = backupUsedVariableList(j).elementTypes + usedVariableList(i).elementOffset = backupUsedVariableList(j).elementOffset + END IF + END IF CASE ELSE 'find and mark as used IF found THEN