Merge pull request #1629 from danielyxie/dev

dont run inf loop check on ns1 scripts
This commit is contained in:
hydroflame
2021-10-29 01:23:33 -04:00
committed by GitHub
4 changed files with 33 additions and 28 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -234,7 +234,6 @@ export function checkInfiniteLoop(code: string): number {
{ {
WhileStatement: (node: acorn.Node, st: any, walkDeeper: walk.WalkerCallback<any>) => { WhileStatement: (node: acorn.Node, st: any, walkDeeper: walk.WalkerCallback<any>) => {
if (nodeHasTrueTest((node as any).test) && !hasAwait(node)) { if (nodeHasTrueTest((node as any).test) && !hasAwait(node)) {
console.log(node);
missingAwaitLine = (code.slice(0, node.start).match(/\n/g) || []).length + 1; missingAwaitLine = (code.slice(0, node.start).match(/\n/g) || []).length + 1;
} else { } else {
(node as any).body && walkDeeper((node as any).body, st); (node as any).body && walkDeeper((node as any).body, st);

View File

@ -227,11 +227,9 @@ export function Root(props: IProps): React.ReactElement {
setFilename(event.target.value); setFilename(event.target.value);
} }
function updateCode(newCode?: string): void { function infLoop(newCode: string): void {
if (newCode === undefined) return; if (editorRef.current === null) return;
lastCode = newCode; if (!filename.endsWith(".ns") && !filename.endsWith(".js")) return;
if (editorRef.current !== null) {
lastPosition = editorRef.current.getPosition();
const awaitWarning = checkInfiniteLoop(newCode); const awaitWarning = checkInfiniteLoop(newCode);
if (awaitWarning !== -1) { if (awaitWarning !== -1) {
const newDecorations = editorRef.current.deltaDecorations(decorations, [ const newDecorations = editorRef.current.deltaDecorations(decorations, [
@ -257,6 +255,14 @@ export function Root(props: IProps): React.ReactElement {
setDecorations(newDecorations); setDecorations(newDecorations);
} }
} }
function updateCode(newCode?: string): void {
if (newCode === undefined) return;
lastCode = newCode;
if (editorRef.current !== null) {
lastPosition = editorRef.current.getPosition();
infLoop(newCode);
}
setCode(newCode); setCode(newCode);
updateRAM(newCode); updateRAM(newCode);
} }