diff --git a/src/Terminal/ui/TerminalInput.tsx b/src/Terminal/ui/TerminalInput.tsx index 5f53f3eca..1e4178a04 100644 --- a/src/Terminal/ui/TerminalInput.tsx +++ b/src/Terminal/ui/TerminalInput.tsx @@ -199,6 +199,8 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React }); async function onKeyDown(event: React.KeyboardEvent): Promise { + const ref = terminalInput.current; + // Run command. if (event.key === KEY.ENTER && value !== "") { event.preventDefault(); @@ -285,7 +287,6 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React } const prevCommand = terminal.commandHistory[terminal.commandHistoryIndex]; saveValue(prevCommand); - const ref = terminalInput.current; if (ref) { setTimeout(function () { ref.selectionStart = ref.selectionEnd = 10000; @@ -321,7 +322,7 @@ export function TerminalInput({ terminal, router, player }: IProps): React.React // Extra Bash Emulation Hotkeys, must be enabled through options if (Settings.EnableBashHotkeys) { - if (event.code === KEYCODE.C && event.ctrlKey) { + if (event.code === KEYCODE.C && event.ctrlKey && ref && ref.selectionStart === ref.selectionEnd) { event.preventDefault(); modifyInput("clearall"); }