diff --git a/apps/remix-ide-e2e/src/tests/homeTab.test.ts b/apps/remix-ide-e2e/src/tests/homeTab.test.ts new file mode 100644 index 0000000000..81f78be22a --- /dev/null +++ b/apps/remix-ide-e2e/src/tests/homeTab.test.ts @@ -0,0 +1,20 @@ +'use strict' +import { NightwatchBrowser } from 'nightwatch' +import init from '../helpers/init' + +module.exports = { + + before: function (browser: NightwatchBrowser, done: VoidFunction) { + init(browser, done) + }, + + 'Should create new file': function (browser: NightwatchBrowser) { + browser + .waitForElementVisible('*[data-id="homeTabNewFile"]') + .click('*[data-id="homeTabNewFile"]') + .waitForElementContainsText('*[data-id$="/blank"]', '', 60000) + .sendKeys('*[data-id$="/blank"] .remixui_items', 'newTestFile') + .sendKeys('*[data-id$="/blank"] .remixui_items', browser.Keys.ENTER) + .waitForElementVisible('li[data-id="treeViewLitreeViewItemnewTestFile.sol"]') + } +} \ No newline at end of file diff --git a/apps/remix-ide/src/app/editor/editor.js b/apps/remix-ide/src/app/editor/editor.js index 99e921d63b..23601242f3 100644 --- a/apps/remix-ide/src/app/editor/editor.js +++ b/apps/remix-ide/src/app/editor/editor.js @@ -5,7 +5,6 @@ import { EditorUI } from '@remix-ui/editor' // eslint-disable-line import { Plugin } from '@remixproject/engine' import * as packageJson from '../../../../../package.json' import { PluginViewWrapper } from '@remix-ui/helper' -import { exists } from 'fs' const EventManager = require('../../lib/events') @@ -199,7 +198,7 @@ class Editor extends Plugin { return ext && this.modes[ext] ? this.modes[ext] : this.modes.txt } - async handleTypeScriptDependenciesOf (path, content, readFile) { + async handleTypeScriptDependenciesOf (path, content, readFile, exists) { if (path.endsWith('.ts')) { // extract the import, resolve their content // and add the imported files to Monaco through the `addModel` diff --git a/apps/remix-ide/src/app/files/fileManager.ts b/apps/remix-ide/src/app/files/fileManager.ts index 49135860bf..847d6f3f02 100644 --- a/apps/remix-ide/src/app/files/fileManager.ts +++ b/apps/remix-ide/src/app/files/fileManager.ts @@ -635,7 +635,7 @@ class FileManager extends Plugin { try { // This make sure dependencies are loaded in the editor context. // This ensure monaco is aware of deps artifacts, so it can provide basic features like "go to" symbols. - await this.editor.handleTypeScriptDependenciesOf(file, content, path => this.readFile(path)) + await this.editor.handleTypeScriptDependenciesOf(file, content, path => this.readFile(path), path => this.exists(path)) } catch (e) { console.log('unable to handle TypeScript dependencies of', file) } diff --git a/apps/remix-ide/src/app/panels/file-panel.js b/apps/remix-ide/src/app/panels/file-panel.js index 71c637406b..d6a3708269 100644 --- a/apps/remix-ide/src/app/panels/file-panel.js +++ b/apps/remix-ide/src/app/panels/file-panel.js @@ -102,10 +102,7 @@ module.exports = class Filepanel extends ViewPlugin { createNewFile () { return new Promise((resolve, reject) => { - const provider = this.fileManager.currentFileProvider() - const dir = provider.workspace || '/' - - this.emit('createNewFileInputReducerEvent', dir, (err, data) => { + this.emit('createNewFileInputReducerEvent', '/', (err, data) => { if (err) reject(err) else resolve(data) }) @@ -114,10 +111,7 @@ module.exports = class Filepanel extends ViewPlugin { uploadFile (target) { return new Promise((resolve, reject) => { - const provider = this.fileManager.currentFileProvider() - const dir = provider.workspace || '/' - - return this.emit('uploadFileReducerEvent', dir, target, (err, data) => { + return this.emit('uploadFileReducerEvent', '/', target, (err, data) => { if (err) reject(err) else resolve(data) }) 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 cd9e5d6cd5..a0f6b9f550 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 @@ -24,7 +24,8 @@ export default class CodeParserAntlrService { worker: Worker parserStartTime: number = 0 workerTimer: NodeJS.Timer - parserTreshHold: number = 10 + parserThreshold: number = 10 + parserThresholdSampleAmount = 3 cache: { [name: string]: { text: string, @@ -58,7 +59,7 @@ export default class CodeParserAntlrService { ast: ev.data.ast, duration: ev.data.duration, blocks: ev.data.blocks, - blockDurations: self.cache[ev.data.file].blockDurations? [...self.cache[ev.data.file].blockDurations.slice(-3), ev.data.blockDuration]: [ev.data.blockDuration] + blockDurations: self.cache[ev.data.file].blockDurations? [...self.cache[ev.data.file].blockDurations.slice(-self.parserThresholdSampleAmount), ev.data.blockDuration]: [ev.data.blockDuration] } self.setFileParsingState(ev.data.file) } @@ -70,17 +71,15 @@ export default class CodeParserAntlrService { setFileParsingState(file: string) { if (this.cache[file]) { - if (this.cache[file].blockDurations && this.cache[file].blockDurations.length > 3) { + if (this.cache[file].blockDurations && this.cache[file].blockDurations.length > this.parserThresholdSampleAmount) { // calculate average of durations to determine if the parsing should be disabled const values = [...this.cache[file].blockDurations] const average = values.reduce((a, b) => a + b, 0) / values.length - if (average > this.parserTreshHold) { + if (average > this.parserThreshold) { this.cache[file].parsingEnabled = false - this.plugin.call('notification', 'toast','Some autocomplete features will be temporarily disabled because the file takes too long to process.') } else { this.cache[file].parsingEnabled = true - } - + } } } } @@ -249,7 +248,7 @@ export default class CodeParserAntlrService { const startTime = Date.now() const blocks = (SolidityParser as any).parseBlock(fileContent, { loc: true, range: true, tolerant: true }) 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.cache[this.plugin.currentFile].blockDurations = [...this.cache[this.plugin.currentFile].blockDurations.slice(-this.parserThresholdSampleAmount), Date.now() - startTime] this.setFileParsingState(this.plugin.currentFile) } if (blocks) this.cache[this.plugin.currentFile].blocks = blocks diff --git a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx index 3f7500f653..6fe4d449cc 100644 --- a/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx +++ b/libs/remix-ui/home-tab/src/lib/remix-ui-home-tab.tsx @@ -273,7 +273,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => {

- +