Stop printing garbage characters for F1,F2.. keys (#12835)

This commit is contained in:
Tommaso Sciortino
2025-11-10 10:56:05 -08:00
committed by GitHub
parent 2136598e87
commit 3c9052a751
10 changed files with 70 additions and 18 deletions

View File

@@ -17,6 +17,7 @@ import {
stripUnsafeCharacters,
getCachedStringWidth,
} from '../../utils/textUtils.js';
import type { Key } from '../../contexts/KeypressContext.js';
import type { VimAction } from './vim-buffer-actions.js';
import { handleVimAction } from './vim-buffer-actions.js';
@@ -1907,14 +1908,7 @@ export function useTextBuffer({
);
const handleInput = useCallback(
(key: {
name: string;
ctrl: boolean;
meta: boolean;
shift: boolean;
paste: boolean;
sequence: string;
}): void => {
(key: Key): void => {
const { sequence: input } = key;
if (key.paste) {
@@ -1964,7 +1958,7 @@ export function useTextBuffer({
else if (key.name === 'delete' || (key.ctrl && key.name === 'd')) del();
else if (key.ctrl && !key.shift && key.name === 'z') undo();
else if (key.ctrl && key.shift && key.name === 'z') redo();
else if (input && !key.ctrl && !key.meta && key.name !== 'tab') {
else if (key.insertable) {
insert(input, { paste: key.paste });
}
},
@@ -2266,14 +2260,7 @@ export interface TextBuffer {
/**
* High level "handleInput" receives what Ink gives us.
*/
handleInput: (key: {
name: string;
ctrl: boolean;
meta: boolean;
shift: boolean;
paste: boolean;
sequence: string;
}) => void;
handleInput: (key: Key) => void;
/**
* Opens the current buffer contents in the user's preferred terminal text
* editor ($VISUAL or $EDITOR, falling back to "vi"). The method blocks