Commit 80b7a7e2 authored by lianahus's avatar lianahus Committed by Aniket

uodate current on enter

parent 908d897f
...@@ -69,6 +69,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -69,6 +69,7 @@ module.exports = class TestTab extends ViewPlugin {
updateForNewCurrent (file) { updateForNewCurrent (file) {
this.updateGenerateFileAction(file) this.updateGenerateFileAction(file)
if (!this.areTestsRunning) this.updateRunAction(file) if (!this.areTestsRunning) this.updateRunAction(file)
this.updateTestFileList()
this.testTabLogic.getTests((error, tests) => { this.testTabLogic.getTests((error, tests) => {
if (error) return tooltip(error) if (error) return tooltip(error)
this.data.allTests = tests this.data.allTests = tests
...@@ -566,15 +567,24 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -566,15 +567,24 @@ module.exports = class TestTab extends ViewPlugin {
else return input.trim() else return input.trim()
} }
doesOptionAlreadyAdded (text) { pathAdded (text) {
for (const option of this.uiPathList.querySelectorAll('option')) { for (const option of this.uiPathList.querySelectorAll('option')) {
if (option.innerHTML === text) return true if (option.innerHTML === text) return true
} }
return false return false
} }
handleTestDirInput () { async handleTestDirInput (e) {
const testDirInput = this.trimTestDirInput(this.inputPath.value) const testDirInput = this.trimTestDirInput(this.inputPath.value)
if (e.key === 'Enter') {
this.inputPath.value = this.trimTestDirInput(testDirInput)
if (await this.testTabLogic.pathExists(testDirInput)) {
this.testTabLogic.setCurrentPath(testDirInput)
this.updateForNewCurrent()
return
}
}
if (testDirInput) { if (testDirInput) {
if (testDirInput.endsWith('/')) { if (testDirInput.endsWith('/')) {
// check if the options list already contains the options // check if the options list already contains the options
...@@ -585,7 +595,7 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -585,7 +595,7 @@ module.exports = class TestTab extends ViewPlugin {
this.updateDirList(testDirInput) this.updateDirList(testDirInput)
} else { } else {
// If there is no matching folder in the workspace with entered text, enable Create button // If there is no matching folder in the workspace with entered text, enable Create button
if (this.doesOptionAlreadyAdded(testDirInput)) { if (this.pathAdded(testDirInput)) {
this.createTestFolder.disabled = true this.createTestFolder.disabled = true
this.updateGenerateFileAction().disabled = false this.updateGenerateFileAction().disabled = false
} else { } else {
...@@ -614,8 +624,19 @@ module.exports = class TestTab extends ViewPlugin { ...@@ -614,8 +624,19 @@ module.exports = class TestTab extends ViewPlugin {
data-id="uiPathInput" data-id="uiPathInput"
name="utPath" name="utPath"
style="background-image: var(--primary);" style="background-image: var(--primary);"
onkeyup=${(e) => this.handleTestDirInput()} onkeyup=${(e) => this.handleTestDirInput(e)}
onchange=${(e) => { if (!this.createTestFolder.disabled) this.handleCreateFolder() }} onchange=${(e) => {
console.log("onchange")
if (!this.createTestFolder.disabled) return // this.handleCreateFolder()
else {
this.inputPath.value = this.trimTestDirInput(this.inputPath.value)
if (this.testTabLogic.pathExists(this.inputPath.value)) {
this.inputPath.value = this.trimTestDirInput(this.inputPath.value)
this.testTabLogic.setCurrentPath(this.inputPath.value)
this.updateForNewCurrent()
}
}
}}
/>` />`
this.createTestFolder = yo` this.createTestFolder = yo`
......
...@@ -21,6 +21,13 @@ class TestTabLogic { ...@@ -21,6 +21,13 @@ class TestTabLogic {
fileProvider.exists(path, (e, res) => { if (!res) fileProvider.createDir(path) }) fileProvider.exists(path, (e, res) => { if (!res) fileProvider.createDir(path) })
} }
pathExists(path) {
// Checking to ignore the value which contains only whitespaces
if (!path || !(/\S/.test(path))) return
const fileProvider = this.fileManager.fileProviderOf(path.split('/')[0])
return fileProvider.exists(path, (e, res) => { return res })
}
generateTestFile () { generateTestFile () {
let fileName = this.fileManager.currentFile() let fileName = this.fileManager.currentFile()
const hasCurrent = !!fileName && this.fileManager.currentFile().split('.').pop().toLowerCase() === 'sol' const hasCurrent = !!fileName && this.fileManager.currentFile().split('.').pop().toLowerCase() === 'sol'
......
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