Skip to content

Commit

Permalink
Fix for directives not respecting previous indents (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
worksofliam committed Aug 11, 2023
1 parent 83a5380 commit 898f84e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
1 change: 1 addition & 0 deletions language/document.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@ export default class Document {
newLineToken = tokens[lastLine.index];
const indent = statementTokens[0] && newLineToken ? (statementTokens[0].range.start - newLineToken.range.end) : 0;
this.addStatement(indent, statementTokens);
lastLine.need = true;

statementStart = {
index: i+1
Expand Down
23 changes: 23 additions & 0 deletions tests/suite/linter.js
Original file line number Diff line number Diff line change
Expand Up @@ -3210,5 +3210,28 @@ exports.issue_234 = async () => {
IncorrectVariableCase: true
}, cache);

assert.strictEqual(indentErrors.length, 0);
}

exports.issue_238 = async () => {
const lines = [
`**FREE`,
`/Copy Qcpysrc,Hspecle`,
`// Prototypes`,
`/Copy Qcpysrc,Copybook1`,
`/Copy Qcpysrc,Copybook2`,
`/Copy Qcpysrc,Copybook3`,
`/Copy Qcpysrc,Copybook4`,
`/Copy Qcpysrc,Copybook5`,
`Dcl-S MyParm1 Char(1) Const;`,
`Dcl-S MyParm2 Char(1) Const;`,
].join(`\n`);

const parser = parserSetup();
const cache = await parser.getDocs(uri, lines);
const { indentErrors, errors } = Linter.getErrors({ uri, content: lines }, {
indent: 2
}, cache);

assert.strictEqual(indentErrors.length, 0);
}

0 comments on commit 898f84e

Please sign in to comment.