From 8aed029b2472408fd869852ee3e7775cc21bf707 Mon Sep 17 00:00:00 2001 From: Wyatt Lipscomb <35582368+WyattSL@users.noreply.github.com> Date: Mon, 5 Jun 2023 12:06:08 +0000 Subject: [PATCH] 3.0.7 --- CHANGELOG.md | 3 ++ extension.js | 29 ++++++++++++-------- package.json | 2 +- syntaxes/greyscript.tmLanguage.json.template | 4 +-- 4 files changed, 24 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4fefe..b1d9516 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,6 @@ +# 3.0.7 +- Fix some syntax + # 3.0.6 **This update is for 3.0.1 - 3.0.6 merging from preview into stable.** - (3.0.1) Documentation is now automatically pulled from [Greydocs](https://wyattsl.github.io/greydocs) diff --git a/extension.js b/extension.js index 1eb5b7c..abac566 100644 --- a/extension.js +++ b/extension.js @@ -408,6 +408,7 @@ function activate(context) { let params = assignment.match(/(?<=\()(.*?)(?=\))/)[0].split(`,`); let plist = ``; for (let p of params) { + p=p.trim(); let pd = FancyParse.params[p] ? FancyParse.params[p] : {type:[`any`],description:``,optional:false}; plist += `${p}${pd.optional ? '?' : ''}: ${pd.type.join("|")}, `; }; @@ -536,7 +537,7 @@ function activate(context) { } // Add result - docs.title += ": " + (ReturnData[type][cmd] || []).map(d => d.type + (d.type == "Map" || d.type == "List" ? `[${d.subType}]` : "")).join(" or "); + docs.title += ": " + (ReturnData[type][cmd] || []).map(d => d.type + (d.type == "Map" || d.type == "List" ? `[${d.subType}]` : "")).join("|"); // Add info/hover text docs.description = HoverData[type][cmd] || ""; @@ -946,18 +947,20 @@ function activate(context) { } function hexToRgb(hex) { - var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(hex); + var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})?$/i.exec(hex); return result ? { r: parseInt(result[1], 16), g: parseInt(result[2], 16), - b: parseInt(result[3], 16) + b: parseInt(result[3], 16), + a: result[4] ? parseInt(result[4], 16) : 255, } : null; } - function rgbToHex(r, g, b) { + function rgbToHex(r, g, b, a) { r = (r * 255).toString(16); g = (g * 255).toString(16); b = (b * 255).toString(16); + a = (a * 255).toString(16); if (r.length == 1) r = "0" + r; @@ -965,8 +968,10 @@ function activate(context) { g = "0" + g; if (b.length == 1) b = "0" + b; + if (a.length == 1) + a = "0"+a; - return "#" + r + g + b; + return "#" + r + g + b + a; } // Returns an array of vscode Ranges for any matching text in the document. @@ -1028,7 +1033,7 @@ function activate(context) { vscode.languages.registerDocumentSemanticTokensProvider('greyscript', { provideDocumentSemanticTokens(document) { - try { + //try { // analyze & return highlighting and stuff. bugout.appendLine(`Providing semantics`); @@ -1101,11 +1106,13 @@ function activate(context) { */ let params = RegExpToRanges(document, /\w+(?:\s|)=(?:\s|)function\((.*)\)/g, 1, (textafs, startline, startchar, endline, endchar) => { + if (!textafs || typeof(textafs) != "string") return; let out = []; let txt = textafs[textafs.length - 1].slice(startchar, endchar); let opts = txt.split(","); for (let o of opts) { let s = o.split("=")[0]; + if (!s) continue; let exe = new RegExp(`(?<=^|,\s?)${s}(?=$|,|=)`).exec(txt); out.push(new vscode.Range(startline, startchar + exe.index, endline, startchar + exe.index + s.length)) } @@ -1145,9 +1152,9 @@ function activate(context) { bugout.appendLine(`Provided ${outcount} tokens!`) return tokensBuilder.build(); - } catch (err) { + /*} catch (err) { bugout.appendLine(`Caught error: ${err}`) - } + }*/ } }, SemanticsLegend); @@ -1156,7 +1163,7 @@ function activate(context) { async provideDocumentColors(document, token) { //let txt = document.getText(); let txt = await GetDocumentText(document); - let reg = /(?:(?:/gi + let reg = /(?:(?:<(?:color|mark)=)?(#[0-9a-f]{6,8})|<(?:color|mark)=\"?(black|blue|green|orange|purple|red|white|yellow)\"?)>/gi let mchs = txt.matchAll(reg); let out = []; let startPos = 0; @@ -1234,9 +1241,9 @@ function activate(context) { return out; }, provideColorPresentations(color, ctx, token) { - let hex = rgbToHex(color.red, color.green, color.blue); + let hex = rgbToHex(color.red, color.green, color.blue, color.alpha); ctx.range = new vscode.Range(ctx.range.start, new vscode.Position(ctx.range.end.line, ctx.range.start.character + hex.length)) - return [vscode.ColorPresentation(hex)] + return [new vscode.ColorPresentation(hex)] } }); diff --git a/package.json b/package.json index 76a92d0..9ac3eda 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/WyattSL" }, "icon": "icon.png", - "version": "3.0.6", + "version": "3.0.7", "repository": { "type": "git", "url": "https://github.com/WyattSL/greyscript.git" diff --git a/syntaxes/greyscript.tmLanguage.json.template b/syntaxes/greyscript.tmLanguage.json.template index b0f3dd1..bd90926 100644 --- a/syntaxes/greyscript.tmLanguage.json.template +++ b/syntaxes/greyscript.tmLanguage.json.template @@ -22,7 +22,7 @@ }, { "name": "support.class", - "match": "(--CLASSES--)" + "match": "\\b(--CLASSES--)\\b" }, { "name": "string.quoted.double", @@ -35,7 +35,7 @@ }, { "name": "keyword.control", - "match": "\\b(if|else|while|for|return|break|continue|function|end if|end function|end for|end while)\\b" + "match": "\\b(if|else|while|then|for|in|return|break|continue|function|end if|end function|end for|end while)\\b" }, { "name": "keyword.operator",