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 {
updateForNewCurrent (file) {
this.updateGenerateFileAction(file)
if (!this.areTestsRunning) this.updateRunAction(file)
this.updateTestFileList()
this.testTabLogic.getTests((error, tests) => {
if (error) return tooltip(error)
this.data.allTests = tests
......@@ -566,15 +567,24 @@ module.exports = class TestTab extends ViewPlugin {
else return input.trim()
}
doesOptionAlreadyAdded (text) {
pathAdded (text) {
for (const option of this.uiPathList.querySelectorAll('option')) {
if (option.innerHTML === text) return true
}
return false
}
handleTestDirInput () {
async handleTestDirInput (e) {
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.endsWith('/')) {
// check if the options list already contains the options
......@@ -585,7 +595,7 @@ module.exports = class TestTab extends ViewPlugin {
this.updateDirList(testDirInput)
} else {
// 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.updateGenerateFileAction().disabled = false
} else {
......@@ -614,8 +624,19 @@ module.exports = class TestTab extends ViewPlugin {
data-id="uiPathInput"
name="utPath"
style="background-image: var(--primary);"
onkeyup=${(e) => this.handleTestDirInput()}
onchange=${(e) => { if (!this.createTestFolder.disabled) this.handleCreateFolder() }}
onkeyup=${(e) => this.handleTestDirInput(e)}
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`
......
......@@ -21,6 +21,13 @@ class TestTabLogic {
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 () {
let fileName = this.fileManager.currentFile()
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