Restore keyboard mode when exiting the editor (#13350)

This commit is contained in:
Tommaso Sciortino
2025-11-19 11:37:30 -08:00
committed by GitHub
parent 3f8d636501
commit 84573992b4
6 changed files with 57 additions and 50 deletions
@@ -207,7 +207,6 @@ describe('InputPrompt', () => {
);
mockedUseKittyKeyboardProtocol.mockReturnValue({
supported: false,
enabled: false,
checking: false,
});
@@ -1244,7 +1243,6 @@ describe('InputPrompt', () => {
beforeEach(() => {
vi.useFakeTimers();
mockedUseKittyKeyboardProtocol.mockReturnValue({
supported: false,
enabled: false,
checking: false,
});
@@ -1328,7 +1326,6 @@ describe('InputPrompt', () => {
name: 'kitty',
setup: () =>
mockedUseKittyKeyboardProtocol.mockReturnValue({
supported: true,
enabled: true,
checking: false,
}),
@@ -404,7 +404,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
if (key.paste) {
// Record paste time to prevent accidental auto-submission
if (!isTerminalPasteTrusted(kittyProtocol.supported)) {
if (!isTerminalPasteTrusted(kittyProtocol.enabled)) {
setRecentUnsafePasteTime(Date.now());
// Clear any existing paste timeout
@@ -820,7 +820,7 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
recentUnsafePasteTime,
commandSearchActive,
commandSearchCompletion,
kittyProtocol.supported,
kittyProtocol.enabled,
tryLoadQueuedMessages,
setBannerVisible,
],
@@ -20,6 +20,7 @@ import {
import type { Key } from '../../contexts/KeypressContext.js';
import type { VimAction } from './vim-buffer-actions.js';
import { handleVimAction } from './vim-buffer-actions.js';
import { enableSupportedProtocol } from '../../utils/kittyProtocolDetector.js';
export type Direction =
| 'left'
@@ -1891,6 +1892,7 @@ export function useTextBuffer({
} catch (err) {
console.error('[useTextBuffer] external editor error', err);
} finally {
enableSupportedProtocol();
if (wasRaw) setRawMode?.(true);
try {
fs.unlinkSync(filePath);