Skip to content

Commit

Permalink
Revert "better reporting for errors when one editor changes, see phet…
Browse files Browse the repository at this point in the history
…sims/joist#941"

This reverts commit 96bbe08.
  • Loading branch information
jessegreenberg committed Sep 17, 2024
1 parent 40004a8 commit 3734aef
Showing 1 changed file with 12 additions and 40 deletions.
52 changes: 12 additions & 40 deletions ph-scale-basics_description_editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -338,23 +338,20 @@ <h3 class="no-pad">State Descriptions for pH Scale</h3>
reloadStrings();
}

// An object like: {
// marker: codeMirror TextMarker,
// line: line number of the error,
// message: error message
// }
// codeMirror TextMarker
const logicTextMarkProperty = { value: null };
const stringsTextMarkProperty = { value: null };

const runCode = async ( code, isLogic ) => {
const textMarkProperty = isLogic ? logicTextMarkProperty : stringsTextMarkProperty;

if ( textMarkProperty.value ) {
textMarkProperty.value.marker.clear();
textMarkProperty.value.clear();
textMarkProperty.value = null;
}

const errorContainer = document.querySelector( '#error-container' );
errorContainer.style.display = 'none';

// eslint-disable-next-line no-undef
const error = await iframe.contentWindow.phet.joist.DescriptionContext.externalLoad( code );
Expand Down Expand Up @@ -382,42 +379,17 @@ <h3 class="no-pad">State Descriptions for pH Scale</h3>
errorContainer.style.display = 'block';
errorContainer.innerHTML = `${isLogic ? 'Logic' : 'Strings'} error, line: ${line}<br>${message}`;

textMarkProperty.value = {

// codeMirror text marker, need to save a reference to clear it
marker: editor.markText( {
line: line - 1,
ch: column - 1
}, {
line: line,
ch: 0
}, {
className: 'syntax-error',
title: message
} ),

// Line and message to display in the error container
textMarkProperty.value = editor.markText( {
line: line - 1,
ch: column - 1
}, {
line: line,
message: message
};
}

// Display an error message for either error - don't hide just because one is successful
if ( logicTextMarkProperty.value || stringsTextMarkProperty.value ) {
errorContainer.style.display = 'block';
if ( logicTextMarkProperty.value ) {
const mark = logicTextMarkProperty.value;
errorContainer.innerHTML = 'Logic error, line: ' + mark.line + '<br>' + mark.message;
}
else {
const mark = stringsTextMarkProperty.value;
errorContainer.innerHTML = 'Strings error, line: ' + mark.line + '<br>' + mark.message;
}
}
else {
errorContainer.style.display = 'none';
ch: 0
}, {
className: 'syntax-error',
title: message
} );
}

};

logicEditor.on( 'change', async editor => {
Expand Down

0 comments on commit 3734aef

Please sign in to comment.