Skip to content

Commit

Permalink
chore: concertoEditor build fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vinyl-Davyl committed Jul 16, 2024
1 parent 2b01326 commit ae167ab
Showing 1 changed file with 23 additions and 17 deletions.
40 changes: 23 additions & 17 deletions src/ConcertoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const options: editor.IStandaloneEditorConstructionOptions = {
automaticLayout: true,
scrollBeyondLastLine: false,
};

const concertoKeywords = [
"map",
"concept",
Expand All @@ -32,6 +33,7 @@ const concertoKeywords = [
"transaction",
"event",
];

const concertoTypes = [
"String",
"Integer",
Expand All @@ -55,27 +57,30 @@ export default function ConcertoEditor({
return error;
}
}, [error]);

useEffect(() => {
let model = monacoEditor?.editor.getModels()[0];
if (ctoErr && monacoEditor) {
const model = monacoEditor?.editor.getModels()[0];
if (ctoErr && monacoEditor && model) {
const match = ctoErr.match(/Line (\d+) column (\d+)/);

const lineNumber = parseInt(match[1]);
const columnNumber = parseInt(match[2]);
monacoEditor?.editor.setModelMarkers(model, "customMarker", [
{
startLineNumber: lineNumber,
startColumn: columnNumber - 1,
endLineNumber: lineNumber,
endColumn: columnNumber + 1,
message: ctoErr,
severity: MarkerSeverity.Error,
},
]);
} else {
monacoEditor?.editor.setModelMarkers(model, "customMarker", []);
if (match) {
const lineNumber = parseInt(match[1], 10);
const columnNumber = parseInt(match[2], 10);
monacoEditor.editor.setModelMarkers(model, "customMarker", [
{
startLineNumber: lineNumber,
startColumn: columnNumber - 1,
endLineNumber: lineNumber,
endColumn: columnNumber + 1,
message: ctoErr,
severity: MarkerSeverity.Error,
},
]);
}
} else if (monacoEditor && model) {
monacoEditor.editor.setModelMarkers(model, "customMarker", []);
}
}, [ctoErr, monacoEditor]);

function handleEditorWillMount(monaco: monaco.Monaco) {
monaco.languages.register({
id: "concerto",
Expand Down Expand Up @@ -118,6 +123,7 @@ export default function ConcertoEditor({
],
},
});

monaco.editor.defineTheme("concertoTheme", {
base: "vs",
inherit: true,
Expand Down

0 comments on commit ae167ab

Please sign in to comment.