Skip to content

Commit cdee9d6

Browse files
committed
Fix bug with MI Parsing if there is a list with empty strings
A JavaScript string is a falsy value - but an empty string is valid in these positions - so need to explicitly check for undefined instead of just falsy.
1 parent 2219810 commit cdee9d6

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/backend/mi_parse.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ export function parseMI(output: string): MINode {
213213
let values = [];
214214
values.push(value);
215215
let remaining = output;
216-
while (value = parseCommaValue())
216+
while ((value = parseCommaValue()) !== undefined)
217217
values.push(value);
218218
output = output.substr(1); // ]
219219
return values;

test/mi_parse.test.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,4 +173,9 @@ suite("MI Parse", () => {
173173
assert.equal(MINode.valueOf(obj[1], "@frame.fullname"), undefined);
174174
assert.equal(MINode.valueOf(obj[1], "@frame.line"), undefined);
175175
});
176+
test("empty string values", () => {
177+
let parsed = parseMI(`15^done,register-names=["r0","pc","","xpsr","","control"]`);
178+
let result = parsed.result('register-names');
179+
assert.deepEqual(result, ["r0", "pc", "", "xpsr", "", "control"]);
180+
});
176181
});

0 commit comments

Comments
 (0)