Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: don't show not valid LABEL in OUTLINE #439

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions src/parser/parser.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,39 @@ suite('Parser', () => {
});
});

suite('getLabelByLine', () => {
// List of test data
const dataList = [
// {
// in: // input test string
// rs: // expected result - label name or undefined
// },
{
in: 'ValidLabel:',
rs: 'ValidLabel',
},
{
in: 'NotValidLabel :',
rs: undefined,
},
];
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 label = Parser['getLabelByLine'](document, 0);
if (label === undefined) {
assert.equal(label, data.rs);
} else {
assert.strictEqual(label.name, data.rs);
}
});
});
});

suite('getRemarkByLine', () => {
// List of test data
const dataList = [
Expand Down
2 changes: 1 addition & 1 deletion src/parser/parser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export class Parser {
private static getLabelByLine(document: vscode.TextDocument, line: number) {
const text = CodeUtil.purify(document.lineAt(line).text);
// [\u4e00-\u9fa5] Chinese unicode characters
const label = /^[ \t]*([\u4e00-\u9fa5_a-zA-Z0-9]+) *:{1}(?!(:|=))/.exec(
const label = /^[ \t]*([\u4e00-\u9fa5_a-zA-Z0-9]+):{1}(?!(:|=))/.exec(
text,
);
if (label) {
Expand Down
Loading