@@ -17,27 +17,27 @@ export class ActonTolkCodeLensProvider implements vscode.CodeLensProvider {
1717 return [ ]
1818 }
1919
20- const text = document . getText ( )
21- const mainRegex = / f u n \s + m a i n \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 ( / f u n \s + m a i n \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