Skip to content

Commit f68bee6

Browse files
committed
allow ! when input is non-empty
1 parent 6571c87 commit f68bee6

File tree

2 files changed

+36
-4
lines changed

2 files changed

+36
-4
lines changed

cli/src/state/atoms/__tests__/shell.test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,31 @@ describe("shell mode - comprehensive tests", () => {
444444
expect(store.get(shellModeActiveAtom)).toBe(false)
445445
expect(store.get(inputModeAtom)).toBe("normal")
446446
})
447+
448+
it("should insert '!' when Shift+1 is pressed with text in input", async () => {
449+
const shift1Key: Key = {
450+
name: "shift-1",
451+
sequence: "!",
452+
ctrl: false,
453+
meta: false,
454+
shift: true,
455+
paste: false,
456+
}
457+
458+
// Add text to input
459+
store.set(setTextAtom, "some command")
460+
expect(store.get(textBufferStringAtom)).toBe("some command")
461+
462+
// Press Shift+1
463+
await store.set(keyboardHandlerAtom, shift1Key)
464+
465+
// Should NOT activate shell mode
466+
expect(store.get(shellModeActiveAtom)).toBe(false)
467+
expect(store.get(inputModeAtom)).toBe("normal")
468+
469+
// Should insert "!" into the text
470+
expect(store.get(textBufferStringAtom)).toBe("some command!")
471+
})
447472
})
448473

449474
describe("edge cases", () => {

cli/src/state/atoms/keyboard.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -811,10 +811,17 @@ function handleGlobalHotkeys(get: any, set: any, key: Key): boolean {
811811
return true
812812
}
813813
break
814-
case "shift-1":
815-
// Toggle shell mode with Shift+1 or Shift+!
816-
set(toggleShellModeAtom)
817-
return true
814+
case "shift-1": {
815+
// Toggle shell mode with Shift+1 or Shift+! only if input is empty
816+
const isEmpty = get(textBufferIsEmptyAtom)
817+
if (isEmpty) {
818+
// Input is empty, toggle shell mode
819+
set(toggleShellModeAtom)
820+
return true
821+
}
822+
// Input has text, don't consume the key - let it be inserted as "!"
823+
return false
824+
}
818825
}
819826
return false
820827
}

0 commit comments

Comments
 (0)