fix paste image on windows

This commit is contained in:
LaZzyMan 2026-02-02 17:07:39 +08:00
parent b28e5c4c0f
commit 1050163804
9 changed files with 169 additions and 402 deletions

View file

@ -11,6 +11,7 @@ import { defaultKeyBindings } from '../config/keyBindings.js';
import type { Key } from './hooks/useKeypress.js';
describe('keyMatchers', () => {
const isWindows = process.platform === 'win32';
const createKey = (name: string, mods: Partial<Key> = {}): Key => ({
name,
ctrl: false,
@ -50,7 +51,7 @@ describe('keyMatchers', () => {
[Command.OPEN_EXTERNAL_EDITOR]: (key: Key) =>
key.ctrl && (key.name === 'x' || key.sequence === '\x18'),
[Command.PASTE_CLIPBOARD_IMAGE]: (key: Key) =>
(key.ctrl || key.meta) && key.name === 'v',
(isWindows ? key.meta : key.ctrl || key.meta) && key.name === 'v',
[Command.SHOW_ERROR_DETAILS]: (key: Key) => key.ctrl && key.name === 'o',
[Command.TOGGLE_TOOL_DESCRIPTIONS]: (key: Key) =>
key.ctrl && key.name === 't',
@ -218,11 +219,12 @@ describe('keyMatchers', () => {
},
{
command: Command.PASTE_CLIPBOARD_IMAGE,
positive: [
createKey('v', { ctrl: true }),
createKey('v', { meta: true }),
],
negative: [createKey('v'), createKey('c', { ctrl: true })],
positive: isWindows
? [createKey('v', { meta: true })]
: [createKey('v', { ctrl: true }), createKey('v', { meta: true })],
negative: isWindows
? [createKey('v', { ctrl: true }), createKey('v')]
: [createKey('v'), createKey('c', { ctrl: true })],
},
// App level bindings