File tree Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Expand file tree Collapse file tree 3 files changed +47
-4
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,27 @@ export namespace Debugger {
116
116
Send . frames ( frames ) ;
117
117
}
118
118
119
+ const supportsUtf8Identifiers = ( ( ) => {
120
+ const identifier = `${ string . char ( 226 ) } ${ string . char ( 143 ) } ${ string . char ( 176 ) } ` ;
121
+ const [ , err ] = loadLuaString ( `local ${ identifier } = true return ${ identifier } ` ) ;
122
+ return err === undefined ;
123
+ } ) ( ) ;
124
+
125
+ function isValidIdentifier ( name : string ) {
126
+ if ( supportsUtf8Identifiers ) {
127
+ for ( const [ c ] of name . gmatch ( "[^a-zA-Z0-9_]" ) ) {
128
+ const [ a ] = c . byte ( ) ;
129
+ if ( a && a < 128 ) {
130
+ return false ;
131
+ }
132
+ }
133
+ return true ;
134
+ } else {
135
+ const [ invalidChar ] = name . match ( "[^a-zA-Z0-9_]" ) ;
136
+ return invalidChar === undefined ;
137
+ }
138
+ }
139
+
119
140
function getLocals ( level : number , thread ?: Thread ) : Locals {
120
141
const locs : Locals = { } ;
121
142
@@ -149,8 +170,7 @@ export namespace Debugger {
149
170
break ;
150
171
}
151
172
152
- const [ invalidChar ] = name . match ( "[^a-zA-Z0-9_]" ) ;
153
- if ( ! invalidChar ) {
173
+ if ( isValidIdentifier ( name ) ) {
154
174
locs [ name ] = { val, index, type : type ( val ) } ;
155
175
}
156
176
@@ -258,8 +278,7 @@ export namespace Debugger {
258
278
259
279
function mapName ( sourceName : string , isProperty : boolean ) {
260
280
if ( isProperty ) {
261
- const [ illegalChar ] = sourceName . match ( "[^A-Za-z0-9_]" ) ;
262
- if ( illegalChar ) {
281
+ if ( isValidIdentifier ( sourceName ) ) {
263
282
return `["${ sourceName } "]` ;
264
283
} else {
265
284
return `.${ sourceName } ` ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "version" : " 0.2.0" ,
3
+ "configurations" : [
4
+ {
5
+ "name" : " LuaJit" ,
6
+ "type" : " lua-local" ,
7
+ "request" : " launch" ,
8
+ "program" : {
9
+ "lua" : " luajit" ,
10
+ "file" : " main.lua"
11
+ },
12
+ "verbose" : true
13
+ },
14
+ ]
15
+ }
Original file line number Diff line number Diff line change
1
+ function ⏰(⏳, ⏫)
2
+ local function ⏹()
3
+ local ⏺ = " ⏺"
4
+ print (⏳, ⏫, ⏺)
5
+ end
6
+ ⏹()
7
+ end
8
+
9
+ ⏰(" ⏳" , " ⏫" )
You can’t perform that action at this time.
0 commit comments