Skip to content

Commit bdd68ab

Browse files
committed
feat: support for conditions in getLinesForFormat
1 parent 075de31 commit bdd68ab

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/tests/dspf.test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ describe('DisplayFile tests', () => {
2222
` A 20 DSPATR(PR) `,
2323
` A COLOR(YLW) `,
2424
` A FLD0102 10 B 3 5 `,
25+
` A R FORM2 `,
26+
` A 30 SLNO(02) `,
2527
];
2628

2729
it('getRangeForFormat', () => {
@@ -95,6 +97,14 @@ describe('DisplayFile tests', () => {
9597

9698
});
9799

100+
it('getLinesForFormat', () => {
101+
let dds = new DisplayFile();
102+
dds.parse(dspf1);
103+
let lines = DisplayFile.getLinesForFormat(dds.formats[5]);
104+
expect(lines.length).toBe(2);
105+
expect(lines[1]).toBe(` A 30 SLNO(02)`);
106+
});
107+
98108
it('No duplicate RecordInfo', () => {
99109
let dds = new DisplayFile();
100110
dds.parse(dspf1);

src/ui/dspf.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,6 @@ export class DisplayFile {
398398
return { newLines, range };
399399
}
400400

401-
// TODO: test cases
402401
static getLinesForFormat(recordFormat: RecordInfo): string[] {
403402
const lines: string[] = [];
404403

@@ -407,10 +406,9 @@ export class DisplayFile {
407406
}
408407

409408
for (const keyword of recordFormat.keywords) {
410-
// TODO: support conditions
411-
lines.push(
412-
` A ${keyword.name}${keyword.value ? `(${keyword.value})` : ``}`,
413-
);
409+
for (const keyword of recordFormat.keywords) {
410+
lines.push(...keyword.conditional.getLinesWithCondition(` A ${keyword.name}${keyword.value ? `(${keyword.value})` : ``}`));
411+
}
414412
}
415413

416414
return lines;

0 commit comments

Comments
 (0)