Skip to content

Commit

Permalink
error match & monaco model typo fix
Browse files Browse the repository at this point in the history
Signed-off-by: Mahesh Patil <nitro56565@gmail.com>
  • Loading branch information
nitro56565 committed Jul 18, 2024
1 parent 0c7f931 commit d9258e5
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions src/ConcertoEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,25 +23,28 @@ export default function ConcertoEditor( {value, onChange} : {value: string, onCh
}, [error]);
useEffect(() => {
let model = monacoEditor?.editor.getModels()[0];
if (ctoErr && monacoEditor) {
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,
},
]);
if (match) {
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", []);
monacoEditor?.editor.setModelMarkers(model, "customMarker", []);
}
}
}, [ctoErr,monacoEditor]);

function handleEditorWillMount(monaco:monaco.Monaco) {
monaco.languages.register({
id: 'concerto',
Expand Down

0 comments on commit d9258e5

Please sign in to comment.