Skip to content

Commit 5ca5645

Browse files
authored
Merge pull request #30 from WyattSL/preview
3.0.7
2 parents eb0ad49 + 8aed029 commit 5ca5645

File tree

4 files changed

+24
-14
lines changed

4 files changed

+24
-14
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# 3.0.7
2+
- Fix some syntax
3+
14
# 3.0.6
25
**This update is for 3.0.1 - 3.0.6 merging from preview into stable.**
36
- (3.0.1) Documentation is now automatically pulled from [Greydocs](https://wyattsl.github.io/greydocs)

extension.js

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -408,6 +408,7 @@ function activate(context) {
408408
let params = assignment.match(/(?<=\()(.*?)(?=\))/)[0].split(`,`);
409409
let plist = ``;
410410
for (let p of params) {
411+
p=p.trim();
411412
let pd = FancyParse.params[p] ? FancyParse.params[p] : {type:[`any`],description:``,optional:false};
412413
plist += `${p}${pd.optional ? '?' : ''}: ${pd.type.join("|")}, `;
413414
};
@@ -536,7 +537,7 @@ function activate(context) {
536537
}
537538

538539
// 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("|");
540541

541542
// Add info/hover text
542543
docs.description = HoverData[type][cmd] || "";
@@ -946,27 +947,31 @@ function activate(context) {
946947
}
947948

948949
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);
950951
return result ? {
951952
r: parseInt(result[1], 16),
952953
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,
954956
} : null;
955957
}
956958

957-
function rgbToHex(r, g, b) {
959+
function rgbToHex(r, g, b, a) {
958960
r = (r * 255).toString(16);
959961
g = (g * 255).toString(16);
960962
b = (b * 255).toString(16);
963+
a = (a * 255).toString(16);
961964

962965
if (r.length == 1)
963966
r = "0" + r;
964967
if (g.length == 1)
965968
g = "0" + g;
966969
if (b.length == 1)
967970
b = "0" + b;
971+
if (a.length == 1)
972+
a = "0"+a;
968973

969-
return "#" + r + g + b;
974+
return "#" + r + g + b + a;
970975
}
971976

972977
// Returns an array of vscode Ranges for any matching text in the document.
@@ -1028,7 +1033,7 @@ function activate(context) {
10281033
vscode.languages.registerDocumentSemanticTokensProvider('greyscript', {
10291034

10301035
provideDocumentSemanticTokens(document) {
1031-
try {
1036+
//try {
10321037
// analyze & return highlighting and stuff.
10331038
bugout.appendLine(`Providing semantics`);
10341039

@@ -1101,11 +1106,13 @@ function activate(context) {
11011106
*/
11021107

11031108
let params = RegExpToRanges(document, /\w+(?:\s|)=(?:\s|)function\((.*)\)/g, 1, (textafs, startline, startchar, endline, endchar) => {
1109+
if (!textafs || typeof(textafs) != "string") return;
11041110
let out = [];
11051111
let txt = textafs[textafs.length - 1].slice(startchar, endchar);
11061112
let opts = txt.split(",");
11071113
for (let o of opts) {
11081114
let s = o.split("=")[0];
1115+
if (!s) continue;
11091116
let exe = new RegExp(`(?<=^|,\s?)${s}(?=$|,|=)`).exec(txt);
11101117
out.push(new vscode.Range(startline, startchar + exe.index, endline, startchar + exe.index + s.length))
11111118
}
@@ -1145,9 +1152,9 @@ function activate(context) {
11451152

11461153
bugout.appendLine(`Provided ${outcount} tokens!`)
11471154
return tokensBuilder.build();
1148-
} catch (err) {
1155+
/*} catch (err) {
11491156
bugout.appendLine(`Caught error: ${err}`)
1150-
}
1157+
}*/
11511158
}
11521159

11531160
}, SemanticsLegend);
@@ -1156,7 +1163,7 @@ function activate(context) {
11561163
async provideDocumentColors(document, token) {
11571164
//let txt = document.getText();
11581165
let txt = await GetDocumentText(document);
1159-
let reg = /(?:(?:<color=)?(#[0-9a-f]{6})|<color=\"?(black|blue|green|orange|purple|red|white|yellow)\"?)>/gi
1166+
let reg = /(?:(?:<(?:color|mark)=)?(#[0-9a-f]{6,8})|<(?:color|mark)=\"?(black|blue|green|orange|purple|red|white|yellow)\"?)>/gi
11601167
let mchs = txt.matchAll(reg);
11611168
let out = [];
11621169
let startPos = 0;
@@ -1234,9 +1241,9 @@ function activate(context) {
12341241
return out;
12351242
},
12361243
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);
12381245
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)]
12401247
}
12411248
});
12421249

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"url": "https://github.com/WyattSL"
1010
},
1111
"icon": "icon.png",
12-
"version": "3.0.6",
12+
"version": "3.0.7",
1313
"repository": {
1414
"type": "git",
1515
"url": "https://github.com/WyattSL/greyscript.git"

syntaxes/greyscript.tmLanguage.json.template

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
},
2323
{
2424
"name": "support.class",
25-
"match": "(--CLASSES--)"
25+
"match": "\\b(--CLASSES--)\\b"
2626
},
2727
{
2828
"name": "string.quoted.double",
@@ -35,7 +35,7 @@
3535
},
3636
{
3737
"name": "keyword.control",
38-
"match": "\\b(if|else|while|for|return|break|continue|function|end if|end function|end for|end while)\\b"
38+
"match": "\\b(if|else|while|then|for|in|return|break|continue|function|end if|end function|end for|end while)\\b"
3939
},
4040
{
4141
"name": "keyword.operator",

0 commit comments

Comments
 (0)