diff --git a/src/parser/parser.ts b/src/parser/parser.ts index afecb652..8f2facdf 100644 --- a/src/parser/parser.ts +++ b/src/parser/parser.ts @@ -344,7 +344,7 @@ export class Parser { ) { if (line >= 0) { const { text } = document.lineAt(line); - const markMatch = text.match(/^\s*;(.+)/); + const markMatch = text.match(/^\s*;\s*(.+)/); if (markMatch) { return markMatch[1]; } diff --git a/src/test/suite/parser/parser.test.ts b/src/test/suite/parser/parser.test.ts index 32a96653..0e86cd68 100644 --- a/src/test/suite/parser/parser.test.ts +++ b/src/test/suite/parser/parser.test.ts @@ -35,4 +35,41 @@ suite('Parser', () => { }); }); }); + + suite('getRemarkByLine', () => { + // List of test data + let dataList = [ + // { + // in: // input test string + // rs: // expected result + // }, + { + in: ';comment', + rs: 'comment', + }, + { + in: '; comment', + rs: 'comment', + }, + { + in: ' ;comment', + rs: 'comment', + }, + { + in: ' ; comment', + rs: 'comment', + }, + ]; + dataList.forEach((data) => { + test("'" + data.in + "' => '" + data.rs + "'", async () => { + const document = await vscode.workspace.openTextDocument({ + language: 'ahk', + content: data.in, + }); + // Use array access for the private members + const comment = Parser['getRemarkByLine'](document, 0); + assert.strictEqual(comment, data.rs); + }); + }); + }); });