@@ -408,6 +408,7 @@ function activate(context) {
408
408
let params = assignment . match ( / (?< = \( ) ( .* ?) (? = \) ) / ) [ 0 ] . split ( `,` ) ;
409
409
let plist = `` ;
410
410
for ( let p of params ) {
411
+ p = p . trim ( ) ;
411
412
let pd = FancyParse . params [ p ] ? FancyParse . params [ p ] : { type :[ `any` ] , description :`` , optional :false } ;
412
413
plist += `${ p } ${ pd . optional ? '?' : '' } : ${ pd . type . join ( "|" ) } , ` ;
413
414
} ;
@@ -536,7 +537,7 @@ function activate(context) {
536
537
}
537
538
538
539
// Add result
539
- docs . title += ": " + ( ReturnData [ type ] [ cmd ] || [ ] ) . map ( d => d . type + ( d . type == "Map" || d . type == "List" ? `[${ d . subType } ]` : "" ) ) . join ( " or " ) ;
540
+ docs . title += ": " + ( ReturnData [ type ] [ cmd ] || [ ] ) . map ( d => d . type + ( d . type == "Map" || d . type == "List" ? `[${ d . subType } ]` : "" ) ) . join ( "| " ) ;
540
541
541
542
// Add info/hover text
542
543
docs . description = HoverData [ type ] [ cmd ] || "" ;
@@ -946,27 +947,31 @@ function activate(context) {
946
947
}
947
948
948
949
function hexToRgb ( hex ) {
949
- var result = / ^ # ? ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) ? $ / i. exec ( hex ) ;
950
+ var result = / ^ # ? ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) ( [ a - f \d ] { 2 } ) ? $ / i. exec ( hex ) ;
950
951
return result ? {
951
952
r : parseInt ( result [ 1 ] , 16 ) ,
952
953
g : parseInt ( result [ 2 ] , 16 ) ,
953
- b : parseInt ( result [ 3 ] , 16 )
954
+ b : parseInt ( result [ 3 ] , 16 ) ,
955
+ a : result [ 4 ] ? parseInt ( result [ 4 ] , 16 ) : 255 ,
954
956
} : null ;
955
957
}
956
958
957
- function rgbToHex ( r , g , b ) {
959
+ function rgbToHex ( r , g , b , a ) {
958
960
r = ( r * 255 ) . toString ( 16 ) ;
959
961
g = ( g * 255 ) . toString ( 16 ) ;
960
962
b = ( b * 255 ) . toString ( 16 ) ;
963
+ a = ( a * 255 ) . toString ( 16 ) ;
961
964
962
965
if ( r . length == 1 )
963
966
r = "0" + r ;
964
967
if ( g . length == 1 )
965
968
g = "0" + g ;
966
969
if ( b . length == 1 )
967
970
b = "0" + b ;
971
+ if ( a . length == 1 )
972
+ a = "0" + a ;
968
973
969
- return "#" + r + g + b ;
974
+ return "#" + r + g + b + a ;
970
975
}
971
976
972
977
// Returns an array of vscode Ranges for any matching text in the document.
@@ -1028,7 +1033,7 @@ function activate(context) {
1028
1033
vscode . languages . registerDocumentSemanticTokensProvider ( 'greyscript' , {
1029
1034
1030
1035
provideDocumentSemanticTokens ( document ) {
1031
- try {
1036
+ // try {
1032
1037
// analyze & return highlighting and stuff.
1033
1038
bugout . appendLine ( `Providing semantics` ) ;
1034
1039
@@ -1101,11 +1106,13 @@ function activate(context) {
1101
1106
*/
1102
1107
1103
1108
let params = RegExpToRanges ( document , / \w + (?: \s | ) = (?: \s | ) f u n c t i o n \( ( .* ) \) / g, 1 , ( textafs , startline , startchar , endline , endchar ) => {
1109
+ if ( ! textafs || typeof ( textafs ) != "string" ) return ;
1104
1110
let out = [ ] ;
1105
1111
let txt = textafs [ textafs . length - 1 ] . slice ( startchar , endchar ) ;
1106
1112
let opts = txt . split ( "," ) ;
1107
1113
for ( let o of opts ) {
1108
1114
let s = o . split ( "=" ) [ 0 ] ;
1115
+ if ( ! s ) continue ;
1109
1116
let exe = new RegExp ( `(?<=^|,\s?)${ s } (?=$|,|=)` ) . exec ( txt ) ;
1110
1117
out . push ( new vscode . Range ( startline , startchar + exe . index , endline , startchar + exe . index + s . length ) )
1111
1118
}
@@ -1145,9 +1152,9 @@ function activate(context) {
1145
1152
1146
1153
bugout . appendLine ( `Provided ${ outcount } tokens!` )
1147
1154
return tokensBuilder . build ( ) ;
1148
- } catch ( err ) {
1155
+ /* } catch (err) {
1149
1156
bugout.appendLine(`Caught error: ${err}`)
1150
- }
1157
+ }*/
1151
1158
}
1152
1159
1153
1160
} , SemanticsLegend ) ;
@@ -1156,7 +1163,7 @@ function activate(context) {
1156
1163
async provideDocumentColors ( document , token ) {
1157
1164
//let txt = document.getText();
1158
1165
let txt = await GetDocumentText ( document ) ;
1159
- let reg = / (?: (?: < c o l o r = ) ? ( # [ 0 - 9 a - f ] { 6 } ) | < c o l o r = \" ? ( b l a c k | b l u e | g r e e n | o r a n g e | p u r p l e | r e d | w h i t e | y e l l o w ) \" ? ) > / gi
1166
+ let reg = / (?: (?: < (?: c o l o r | m a r k ) = ) ? ( # [ 0 - 9 a - f ] { 6 , 8 } ) | < (?: c o l o r | m a r k ) = \" ? ( b l a c k | b l u e | g r e e n | o r a n g e | p u r p l e | r e d | w h i t e | y e l l o w ) \" ? ) > / gi
1160
1167
let mchs = txt . matchAll ( reg ) ;
1161
1168
let out = [ ] ;
1162
1169
let startPos = 0 ;
@@ -1234,9 +1241,9 @@ function activate(context) {
1234
1241
return out ;
1235
1242
} ,
1236
1243
provideColorPresentations ( color , ctx , token ) {
1237
- let hex = rgbToHex ( color . red , color . green , color . blue ) ;
1244
+ let hex = rgbToHex ( color . red , color . green , color . blue , color . alpha ) ;
1238
1245
ctx . range = new vscode . Range ( ctx . range . start , new vscode . Position ( ctx . range . end . line , ctx . range . start . character + hex . length ) )
1239
- return [ vscode . ColorPresentation ( hex ) ]
1246
+ return [ new vscode . ColorPresentation ( hex ) ]
1240
1247
}
1241
1248
} ) ;
1242
1249
0 commit comments