mirror of
https://github.com/getpaseo/paseo.git
synced 2026-10-24 18:22:38 +00:00
Control+F moves the caret forward on macOS, so chat Find and file pane Find were stealing a keystroke the text editor owns. Chat Find listens on `document` in the capture phase, so the composer received an already-cancelled Control+F and the caret never moved. Each Find surface carried its own copy of the shortcut predicate and only the terminal's was platform-aware. There is now one predicate, `isFindShortcut` in `@/pane-find`, that takes the platform as a parameter: Command without Control on macOS, Control without Command elsewhere, no Shift or Alt. Chat Find, file pane Find, the Find widget's own query box, terminal Find, and the terminal emulator runtime all call it, and `terminal-find-shortcut.ts` is gone. App surfaces source the platform from `findShortcutPlatform()`, which wraps the app's existing `getShortcutOs()`. The predicate stays free of React Native imports because the terminal emulator runtime is bundled on its own into the terminal WebView; its default platform and `getShortcutOs()`'s browser branch now share one user-agent read in `@/utils/mac-user-agent`. Closes #5097
15 lines
619 B
TypeScript
15 lines
619 B
TypeScript
/**
|
|
* What the browser says about the platform. `getShortcutOs()` is the app's
|
|
* answer for keyboard policy and consults native and Electron first; this is the
|
|
* browser half of it, kept free of React Native imports so the terminal WebView
|
|
* bundle can use it too.
|
|
*/
|
|
export function isMacUserAgent(): boolean {
|
|
if (typeof navigator === "undefined") return false;
|
|
const userAgent = navigator.userAgent ?? "";
|
|
const platform = (navigator as Navigator & { platform?: string }).platform ?? "";
|
|
return (
|
|
/Macintosh|Mac OS|iPhone|iPad|iPod/i.test(userAgent) || /Mac|iPhone|iPad|iPod/i.test(platform)
|
|
);
|
|
}
|