From 1dfcb308d135235cb6ac6c28565154c518f22304 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 22 Sep 2022 11:37:47 +0200 Subject: [PATCH] fix state set --- .../plugins/parser/services/code-parser-antlr-service.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/parser/services/code-parser-antlr-service.ts b/apps/remix-ide/src/app/plugins/parser/services/code-parser-antlr-service.ts index 705ff6c2eb..194d591562 100644 --- a/apps/remix-ide/src/app/plugins/parser/services/code-parser-antlr-service.ts +++ b/apps/remix-ide/src/app/plugins/parser/services/code-parser-antlr-service.ts @@ -69,7 +69,6 @@ export default class CodeParserAntlrService { } setFileParsingState(file: string) { - if (this.cache[file]) { if (this.cache[file].blockDurations && this.cache[file].blockDurations.length > 3) { // calculate average of durations to determine if the parsing should be disabled @@ -131,7 +130,8 @@ export default class CodeParserAntlrService { this.cache[this.plugin.currentFile] = { text: '', ast: null, - parsingEnabled: true + parsingEnabled: true, + blockDurations: [] } } if (this.cache[this.plugin.currentFile] && this.cache[this.plugin.currentFile].text !== fileContent) { @@ -248,7 +248,10 @@ export default class CodeParserAntlrService { try { const startTime = Date.now() const blocks = (SolidityParser as any).parseBlock(fileContent, { loc: true, range: true, tolerant: true }) - this.setFileParsingState(this.plugin.currentFile, Date.now() - startTime) + if(this.cache[this.plugin.currentFile] && this.cache[this.plugin.currentFile].blockDurations){ + this.cache[this.plugin.currentFile].blockDurations = [...this.cache[this.plugin.currentFile].blockDurations.slice(-3), Date.now() - startTime] + this.setFileParsingState(this.plugin.currentFile) + } if (blocks) this.cache[this.plugin.currentFile].blocks = blocks return blocks } catch (e) {