Skip to content

Commit ead03cd

Browse files
committed
fix
1 parent 8eb92e1 commit ead03cd

1 file changed

Lines changed: 18 additions & 18 deletions

File tree

editors/code/src/acton/tolk/ActonTolkCodeLensProvider.ts

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,27 +17,27 @@ export class ActonTolkCodeLensProvider implements vscode.CodeLensProvider {
1717
return []
1818
}
1919

20-
const text = document.getText()
21-
const mainRegex = /fun\s+main\s*\(/g
2220
const lenses: vscode.CodeLens[] = []
23-
let match: RegExpExecArray | null
2421

25-
while ((match = mainRegex.exec(text)) !== null) {
26-
const line = document.positionAt(match.index).line
27-
const range = new vscode.Range(line, 0, line, 0)
22+
for (let i = 0; i < document.lineCount; i++) {
23+
const line = document.lineAt(i)
24+
const text = line.text
2825

29-
lenses.push(
30-
new vscode.CodeLens(range, {
31-
title: "$(play) Emulate",
32-
command: "ton.acton.run",
33-
arguments: [document.uri],
34-
}),
35-
new vscode.CodeLens(range, {
36-
title: "Broadcast",
37-
command: "ton.acton.runBroadcast",
38-
arguments: [document.uri],
39-
}),
40-
)
26+
if (/fun\s+main\s*\(/i.test(text)) {
27+
const range = new vscode.Range(i, 0, i, text.length)
28+
lenses.push(
29+
new vscode.CodeLens(range, {
30+
title: "$(play) Emulate",
31+
command: "ton.acton.run",
32+
arguments: [document.uri],
33+
}),
34+
new vscode.CodeLens(range, {
35+
title: "Broadcast",
36+
command: "ton.acton.runBroadcast",
37+
arguments: [document.uri],
38+
}),
39+
)
40+
}
4141
}
4242

4343
return lenses

0 commit comments

Comments
 (0)