Unverified Commit 9067c636 authored by yann300's avatar yann300 Committed by GitHub

Merge pull request #769 from ethereum/open-focus

Open manually created file
parents 11c3db77 4a083e2c
...@@ -24,7 +24,7 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC ...@@ -24,7 +24,7 @@ function addFile (browser: NightwatchBrowser, name: string, content: NightwatchC
.sendKeys('*[data-id="treeViewLitreeViewItembrowser/blank"] .remixui_items', browser.Keys.ENTER) .sendKeys('*[data-id="treeViewLitreeViewItembrowser/blank"] .remixui_items', browser.Keys.ENTER)
.pause(2000) .pause(2000)
.waitForElementVisible(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`) .waitForElementVisible(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`)
.click(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`) // .click(`li[data-id="treeViewLitreeViewItembrowser/${name}"]`)
.setEditorValue(content.content) .setEditorValue(content.content)
.pause(1000) .pause(1000)
.perform(function () { .perform(function () {
......
...@@ -285,7 +285,12 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -285,7 +285,12 @@ export const FileExplorer = (props: FileExplorerProps) => {
const createFile = await fileManager.writeFile(newName, '') const createFile = await fileManager.writeFile(newName, '')
if (!createFile) { if (!createFile) {
toast('Failed to create file ' + newName) return toast('Failed to create file ' + newName)
} else {
await fileManager.open(newName)
setState(prevState => {
return { ...prevState, focusElement: [{ key: newName, type: 'file' }] }
})
} }
} }
}) })
...@@ -300,7 +305,9 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -300,7 +305,9 @@ export const FileExplorer = (props: FileExplorerProps) => {
if (exists) return if (exists) return
await fileManager.mkdir(dirName) await fileManager.mkdir(dirName)
// addFolder(parentFolder, newFolderPath) setState(prevState => {
return { ...prevState, focusElement: [{ key: newFolderPath, type: 'folder' }] }
})
} catch (e) { } catch (e) {
console.log('error: ', e) console.log('error: ', e)
toast('Failed to create folder: ' + newFolderPath) toast('Failed to create folder: ' + newFolderPath)
...@@ -376,7 +383,7 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -376,7 +383,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
setState(prevState => { setState(prevState => {
const uniquePaths = [...new Set([...prevState.expandPath, ...expandPath])] const uniquePaths = [...new Set([...prevState.expandPath, ...expandPath])]
return { ...prevState, files, expandPath: uniquePaths, focusElement: [{ key: filePath, type: 'file' }] } return { ...prevState, files, expandPath: uniquePaths }
}) })
if (filePath.includes('_test.sol')) { if (filePath.includes('_test.sol')) {
plugin.event.trigger('newTestFileCreated', [filePath]) plugin.event.trigger('newTestFileCreated', [filePath])
...@@ -393,7 +400,7 @@ export const FileExplorer = (props: FileExplorerProps) => { ...@@ -393,7 +400,7 @@ export const FileExplorer = (props: FileExplorerProps) => {
setState(prevState => { setState(prevState => {
const uniquePaths = [...new Set([...prevState.expandPath, ...expandPath])] const uniquePaths = [...new Set([...prevState.expandPath, ...expandPath])]
return { ...prevState, files, expandPath: uniquePaths, focusElement: [{ key: folderPath, type: 'folder' }] } return { ...prevState, files, expandPath: uniquePaths }
}) })
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment