Skip to content

Commit 56a6105

Browse files
committed
Variable array handling
1 parent a7c478a commit 56a6105

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/control/LiveInstrumentRemote.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ export default class LiveInstrumentRemote {
179179

180180
let promises = [];
181181
for (let variable of result) {
182+
if (!variable.value.objectId) continue;
182183
promises.push(this.getVariable(variable.value.objectId, newRemainingDepth)
183184
.then(res => variable.value.value = res));
184185
}
@@ -313,7 +314,7 @@ export default class LiveInstrumentRemote {
313314
test() {
314315
let instrument = new LiveBreakpoint();
315316
instrument.id = randomUUID();
316-
instrument.location = {source: "test/javascript/test.js", line: 5};
317+
instrument.location = {source: "test/javascript/test.js", line: 8};
317318
instrument.hitLimit = 1;
318319
instrument.applyImmediately = true;
319320
instrument.applied = false;

src/util/VariableUtil.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,10 @@ namespace VariableUtil {
2222
return variables;
2323
}
2424

25+
export function encodeVariables(variables: Runtime.PropertyDescriptor[]) {
26+
return variables.map(encodeVariable);
27+
}
28+
2529
export function encodeVariable(variable: Runtime.PropertyDescriptor) {
2630
if (!variable.value) {
2731
return JSON.stringify({
@@ -51,7 +55,8 @@ namespace VariableUtil {
5155
};
5256
obj[variable.name] = "";
5357
if (variable.value.value) {
54-
if (variable.value.type !== 'object') { // TODO: Handle arrays
58+
// Arrays are also objects, so no special handling is necessary
59+
if (variable.value.type !== 'object') {
5560
obj[variable.name] = value;
5661
} else {
5762
obj[variable.name] = variable.value.value.reduce((acc, v) => {

test/javascript/test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
const SourcePlusPlus = require("../../dist/SourcePlusPlus.js");
22
SourcePlusPlus.start({}, true).then(() => {
3+
let testarray = ["this", "is", "an", "array"];
4+
35
console.log("test");
46

57
SourcePlusPlus.liveInstrumentRemote.test();
8+
9+
let i = 2;
610
});

0 commit comments

Comments
 (0)