From 2e3e641ea61034dc69ce1bc04f5989e066e5ecaa Mon Sep 17 00:00:00 2001 From: filip mertens Date: Wed, 28 Sep 2022 14:58:11 +0200 Subject: [PATCH 1/2] react to config changes --- apps/remix-ide/src/app/plugins/config.ts | 3 ++- .../src/app/plugins/parser/code-parser.tsx | 21 +++++++++++++++++-- apps/remix-ide/src/app/tabs/settings-tab.tsx | 3 +++ apps/remix-ide/src/config.js | 7 ++++--- 4 files changed, 28 insertions(+), 6 deletions(-) diff --git a/apps/remix-ide/src/app/plugins/config.ts b/apps/remix-ide/src/app/plugins/config.ts index b65f1ddfa7..b4ff5fe30b 100644 --- a/apps/remix-ide/src/app/plugins/config.ts +++ b/apps/remix-ide/src/app/plugins/config.ts @@ -6,7 +6,8 @@ const profile = { name: 'config', displayName: 'Config', description: 'Config', - methods: ['getAppParameter', 'setAppParameter'] + methods: ['getAppParameter', 'setAppParameter'], + events: ['configChanged'] } export class ConfigPlugin extends Plugin { diff --git a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx index 18276ab676..e378223a81 100644 --- a/apps/remix-ide/src/app/plugins/parser/code-parser.tsx +++ b/apps/remix-ide/src/app/plugins/parser/code-parser.tsx @@ -77,7 +77,7 @@ export class CodeParser extends Plugin { getANTLRBlockAtPosition: (position: any, text?: string) => Promise setCurrentFileAST: (text?: string) => Promise getImports: () => Promise - + constructor(astWalker: any) { super(profile) @@ -133,7 +133,7 @@ export class CodeParser extends Plugin { this.on('fileManager', 'fileRemoved', async () => { await this.importService.setFileTree() }) - + this.on('fileManager', 'currentFileChanged', async () => { await this.call('editor', 'discardLineTexts') const completionSettings = await this.call('config', 'getAppParameter', 'auto-completion') @@ -147,8 +147,25 @@ export class CodeParser extends Plugin { this.compilerService.compiler.loadVersion(true, `${url}?t=${Date.now()}`) }) + this.on('config', 'configChanged', async (config) => { + await this.reload() + }) + + this.on('settings', 'configChanged', async (config) => { + await this.reload() + }) + await this.compilerService.init() + this.on('solidity', 'compilerLoaded', async () => { + await this.reload() + }) + } + async reload(){ + await this.call('editor', 'discardLineTexts') + await this.call('fileDecorator', 'clearFileDecorators') + await this.call('editor', 'clearErrorMarkers', [this.currentFile]) + await this.handleChangeEvents() } /** diff --git a/apps/remix-ide/src/app/tabs/settings-tab.tsx b/apps/remix-ide/src/app/tabs/settings-tab.tsx index 8440ffbfa7..dbc73012be 100644 --- a/apps/remix-ide/src/app/tabs/settings-tab.tsx +++ b/apps/remix-ide/src/app/tabs/settings-tab.tsx @@ -32,6 +32,9 @@ module.exports = class SettingsTab extends ViewPlugin { constructor (config, editor) { super(profile) this.config = config + this.config.events.on('configChanged', (changedConfig) => { + this.emit('configChanged', changedConfig) + }) this.editor = editor this._deps = { themeModule: Registry.getInstance().get('themeModule').api diff --git a/apps/remix-ide/src/config.js b/apps/remix-ide/src/config.js index cb3248ca6c..349e394d07 100644 --- a/apps/remix-ide/src/config.js +++ b/apps/remix-ide/src/config.js @@ -3,7 +3,7 @@ var CONFIG_FILE = '.remix.config' const EventEmitter = require('events') -function Config (storage) { +function Config(storage) { this.items = {} this.unpersistedItems = {} this.events = new EventEmitter() @@ -15,7 +15,7 @@ function Config (storage) { this.items = JSON.parse(config) } } catch (exception) { - /* Do nothing. */ + /* Do nothing. */ } this.exists = function (key) { @@ -30,9 +30,10 @@ function Config (storage) { this.items[key] = content try { storage.set(CONFIG_FILE, JSON.stringify(this.items)) + this.events.emit('configChanged', { key, content }) this.events.emit(key + '_changed', content) } catch (exception) { - /* Do nothing. */ + /* Do nothing. */ } } From 79a4dd1c4bf70fc1be5a453850685d953c6d3f90 Mon Sep 17 00:00:00 2001 From: filip mertens Date: Thu, 29 Sep 2022 09:33:17 +0200 Subject: [PATCH 2/2] pause --- apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts b/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts index 171ad97b6a..9e09df0e8b 100644 --- a/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts +++ b/apps/remix-ide-e2e/src/tests/editorAutoComplete.test.ts @@ -112,7 +112,7 @@ module.exports = { return actions. sendKeys(' someaddress;') .sendKeys(this.Keys.ENTER) - }).pause(2000) + }).pause(4000) .perform(function () { const actions = this.actions({ async: true }); return actions.