Skip to content

Commit

Permalink
Merge pull request #692 from WillRabalais04/bugfixes
Browse files Browse the repository at this point in the history
Bugfix for Issue #606
  • Loading branch information
sampottinger authored May 9, 2023
2 parents 80a5b12 + 9489ad8 commit 5ec4cdc
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions java/src/processing/mode/java/debug/VariableNode.java
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,19 @@ public String getStringValue() {
} else if (getType() == TYPE_ARRAY) {
//instance of int[5] (id=998) --> instance of int[5]
str = value.toString().substring(0, value.toString().lastIndexOf(" "));
/*
*formats multidimensional array values to have the size of the first array in
*the first bracket eg.int[][5]-->int[5][]
*/
// resolves issue #606: https://github.com/processing/processing4/issues/606
if (str.contains("][")) {
String brackets = str.substring(str.indexOf('['));
int arrayDimensions = 0;
String num = brackets.replaceAll("[^\\d]", "");
arrayDimensions = (brackets.length() - num.length()) / 2;
brackets = "[" + num + "]" + "[]".repeat(arrayDimensions - 1);
str = str.substring(0, str.indexOf('[')) + brackets;
}
} else if (getType() == TYPE_STRING) {
str = ((StringReference) value).value(); // use original string value (without quotes)
} else {
Expand Down

0 comments on commit 5ec4cdc

Please sign in to comment.