Skip to content

Commit

Permalink
Correct spacing for extended lines
Browse files Browse the repository at this point in the history
Signed-off-by: worksofliam <[email protected]>
  • Loading branch information
worksofliam committed Dec 9, 2024
1 parent 1524a7d commit df3ecb3
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
2 changes: 1 addition & 1 deletion language/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ export default class Parser {
currentStmtStart.content = (currentStmtStart.content || ``) + baseLine;

if (currentStmtStart.content.endsWith(`-`))
currentStmtStart.content = currentStmtStart.content.substring(0, currentStmtStart.content.length - 1);
currentStmtStart.content = currentStmtStart.content.substring(0, currentStmtStart.content.length - 1) + ` `;

currentStmtStart.content += LINEEND;

Expand Down
29 changes: 29 additions & 0 deletions tests/suite/references.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,8 @@ test(`references_21_fixed_exec1`, async () => {
expect(tlst.references.every(ref => lines.substring(ref.offset.position, ref.offset.end) === `tlst`)).toBe(true);
});


// Test case is from noxDb
test(`references_22_long_lines`, async () => {
const lines = [
`**free`,
Expand Down Expand Up @@ -1448,4 +1450,31 @@ test(`references_22_long_lines`, async () => {
const pReq = jsonRequest.scope.find(`pReq`);
expect(pReq.references.length).toBe(3);
expect(pReq.references.every(ref => lines.substring(ref.offset.position, ref.offset.end) === `pReq`)).toBe(true);
});

// Test case is from noxDb
test('references_23_before_spaces', async () => {
const lines = [
`**free`,
``,
`dcl-s err ind;`,
`dcl-s row varChar(32766);`,
`dcl-s pRow pointer;`,
`dcl-s id int(10);`,
``,
` // now get that row: here we use the a stringed object to build the where statement via the`,
` pRow = json_sqlResultRow ((`,
` 'Select * -`,
` from noxdbdemo.note2 -`,
` where id = $id -`,
` ')`,
` :'{id:' + %char(id) +'}'`,
` );`,
].join(`\n`);

const cache = await parser.getDocs(uri, lines, { ignoreCache: true, withIncludes: true, collectReferences: true });

const id = cache.find(`id`);
expect(id.references.length).toBe(2);
expect(id.references.every(ref => lines.substring(ref.offset.position, ref.offset.end) === `id`)).toBe(true);
});

0 comments on commit df3ecb3

Please sign in to comment.