Skip to content

Commit 22baa3b

Browse files
committed
Compilation errors
1 parent 26c7400 commit 22baa3b

File tree

4 files changed

+52
-9
lines changed

4 files changed

+52
-9
lines changed

CHANGELOG.md

+8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
11
## ShaderToy extension changelog (major changes only):
2+
- 0.14.254 (28-08-2023)
3+
4+
- Compilation errors in Monaco Editor
5+
- Zoomable Monaco Editor
6+
7+
- 0.14.250 (28-06-2023)
8+
9+
- Monaco code editor added (see [Issue #](https://github.com/patuwwy/ShaderToy-Chrome-Plugin/issues/164))
210

311
- 0.13.247 (22-02-2022)
412

app/background.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
(function() {
22
'use strict';
33

4-
chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
5-
if (request.present) {
6-
chrome.pageAction.show(sender.tab.id);
7-
}
8-
sendResponse({});
4+
chrome.action.onClicked.addListener((tab) => {
5+
chrome.scripting.executeScript({
6+
target: { tabId: tab.id },
7+
function: () => {
8+
// code to be executed in the current tab
9+
}
10+
});
911
});
1012

1113
// Check whether new version is installed

app/manifest.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "Shadertoy unofficial plugin.",
4-
"version": "0.14.250",
4+
"version": "0.14.252",
55
"description": "Shadertoy.com unofficial plugin.",
66
"homepage_url": "https://github.com/patuwwy/ShaderToy-Chrome-Plugin",
77
"background": {

app/shadertoy-plugin.js

+36-3
Original file line numberDiff line numberDiff line change
@@ -837,6 +837,8 @@
837837
} else {
838838
this.f_display_editor('#editor .CodeMirror', false);
839839
}
840+
841+
this.setCompilationErrorsHandler(o_editor_monaco);
840842
}
841843

842844
o_script.onload = function() {
@@ -847,7 +849,7 @@
847849
var f_ChangePass_old = ShaderToy.prototype.ChangePass;
848850

849851
ShaderToy.prototype.ChangePass = function(n_id) {
850-
f_ChangePass_old.call(this, n_id)
852+
f_ChangePass_old.call(this, n_id);
851853

852854
var s_code = gShaderToy.mPass[gShaderToy.mActiveDoc].mDocs.getValue();
853855

@@ -856,8 +858,8 @@
856858

857859
var s_html_editor_choice = `
858860
<div id="editorManager" style="margin-bottom: 5px">
859-
<div id="tab0" onclick="ToyPlug.editPage.f_display_editor('#editor .CodeMirror', false)" class="tab"><label>Orginal Shadertoy Editor</label></div>
860-
<div id="tab1" onclick="ToyPlug.editPage.f_display_editor('#editor .monaco-editor', true)" class="tab"><label>VScode (Monaco) Editor</label></div>
861+
<div onclick="ToyPlug.editPage.f_display_editor('#editor .CodeMirror', false)" class="tab"><label>Orginal Shadertoy Editor</label></div>
862+
<div onclick="ToyPlug.editPage.f_display_editor('#editor .monaco-editor', true)" class="tab"><label>VScode (Monaco) Editor</label></div>
861863
</div>
862864
`;
863865

@@ -890,6 +892,37 @@
890892
)
891893
)
892894
}
895+
896+
handleErrors(errors, isError, errorStr, fromScript, editor) {
897+
console.log("SetModelMarkers");
898+
console.dir(errors)
899+
const monacoErrors = errors.map((shError) => ({
900+
startLineNumber: shError.line.parent.lines.findIndex((p) => Array.isArray(p.widgets)) + 1,
901+
startColumn: 0,
902+
endLineNumber: shError.height,
903+
endColumn: shError.line.text.length + 1,
904+
message: errorStr,
905+
severity: 8
906+
}));
907+
monaco.editor.setModelMarkers(editor.getModel(), "owner", monacoErrors);
908+
console.dir(monacoErrors)
909+
}
910+
911+
setCompilationErrorsHandler(editor) {
912+
console.log("setCompilationErrorsHandler", editor)
913+
const t = this;
914+
const defaultHandler = ShaderToy.prototype.SetErrors;
915+
916+
ShaderToy.prototype.SetErrors = function(isError, errorStr, fromScript) {
917+
defaultHandler.call(this, isError, errorStr, fromScript);
918+
919+
if (isError) {
920+
t.handleErrors(this.mErrors, isError, errorStr, fromScript, editor);
921+
} else {
922+
monaco.editor.setModelMarkers(editor.getModel(), "owner", []);
923+
}
924+
}
925+
}
893926
}
894927

895928
/**

0 commit comments

Comments
 (0)