Skip to content

Commit 1057f5d

Browse files
authored
fix(shell): Empty messages were getting sent when hitting enter over and over again in the prompt. (#1819)
1 parent 8ecd8c6 commit 1057f5d

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

src/adapters/Shell.mjs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ class Shell extends Adapter {
103103
this.#rl.prompt()
104104
break
105105
}
106+
if (input.length === 0) {
107+
this.#rl.prompt()
108+
return
109+
}
106110
if (input.length > 0) {
107111
this.#rl.history.push(input)
108112
}

test/Shell_test.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,28 @@ describe('Shell Adapter Integration Test', () => {
7575
await new Promise(resolve => setTimeout(resolve, 60))
7676
assert.deepEqual(wasCalled, false)
7777
})
78+
it('shows prompt if only spaces were entered', async () => {
79+
let wasCalled = false
80+
robot.respond(/.*/, async res => {
81+
wasCalled = true
82+
await res.reply('hello from the other side')
83+
})
84+
robot.stdin.push(' \n')
85+
robot.stdin.push(null)
86+
await new Promise(resolve => setTimeout(resolve, 60))
87+
assert.deepEqual(wasCalled, false)
88+
})
89+
it('shows prompt if only tabs were entered', async () => {
90+
let wasCalled = false
91+
robot.respond(/.*/, async res => {
92+
wasCalled = true
93+
await res.reply('hello from the other side')
94+
})
95+
robot.stdin.push('\t\t\n')
96+
robot.stdin.push(null)
97+
await new Promise(resolve => setTimeout(resolve, 60))
98+
assert.deepEqual(wasCalled, false)
99+
})
78100
})
79101

80102
describe('Shell Adapter', () => {

0 commit comments

Comments
 (0)