mirror of
https://github.com/stablyai/orca.git
synced 2026-10-13 08:02:52 +00:00
Fix Linux primary selection paste inside Orca
This commit is contained in:
@@ -36,6 +36,7 @@ import { isMarkdownComment } from '@/lib/diff-comment-compat'
|
||||
import { useDiffCommentDecorator } from '../diff-comments/useDiffCommentDecorator'
|
||||
import { DiffCommentPopover } from '../diff-comments/DiffCommentPopover'
|
||||
import { getDiffCommentPopoverLeft } from '../diff-comments/diff-comment-popover-position'
|
||||
import { isLinuxUserAgent } from '../terminal-pane/pane-helpers'
|
||||
|
||||
type MonacoEditorProps = {
|
||||
filePath: string
|
||||
@@ -640,7 +641,11 @@ export default function MonacoEditor({
|
||||
addExtraSpaceOnTop: false,
|
||||
autoFindInSelection: 'never',
|
||||
seedSearchStringFromSelection: 'never'
|
||||
}
|
||||
},
|
||||
// Why: Monaco has its own Linux primary-selection integration; keep
|
||||
// it aligned with Orca's app-level opt-out instead of relying on the
|
||||
// global DOM hook, which does not own Monaco's rendered line surface.
|
||||
selectionClipboard: settings?.primarySelectionMiddleClickPaste ?? isLinuxUserAgent()
|
||||
}}
|
||||
path={filePath}
|
||||
// Why: keepCurrentModel preserves the Monaco text model so undo/redo
|
||||
|
||||
@@ -45,7 +45,10 @@ export function usePrimarySelectionPaste(enabled: boolean): void {
|
||||
return target === pendingMiddleTarget || pendingMiddleTarget.contains(target)
|
||||
}
|
||||
|
||||
const rememberPendingTarget = (event: MouseEvent): boolean => {
|
||||
const rememberPendingTarget = (
|
||||
event: MouseEvent,
|
||||
options?: { allowNativeLinuxPaste?: boolean }
|
||||
): boolean => {
|
||||
if (event.button !== 1) {
|
||||
return false
|
||||
}
|
||||
@@ -53,6 +56,12 @@ export function usePrimarySelectionPaste(enabled: boolean): void {
|
||||
if (!target) {
|
||||
return false
|
||||
}
|
||||
if (options?.allowNativeLinuxPaste && isLinuxUserAgent()) {
|
||||
// Why: Chromium already implements X11 primary paste for editable DOM
|
||||
// controls. Suppressing that native path can turn a working OS paste
|
||||
// into a no-op before Orca's async fallback runs.
|
||||
return false
|
||||
}
|
||||
pendingMiddleTarget = target
|
||||
pendingMiddleUntil = Date.now() + 750
|
||||
return true
|
||||
@@ -127,7 +136,7 @@ export function usePrimarySelectionPaste(enabled: boolean): void {
|
||||
}
|
||||
|
||||
const onMouseDown = (event: MouseEvent): void => {
|
||||
rememberPendingTarget(event)
|
||||
rememberPendingTarget(event, { allowNativeLinuxPaste: true })
|
||||
}
|
||||
|
||||
const onMouseUp = (event: MouseEvent): void => {
|
||||
@@ -152,9 +161,14 @@ export function usePrimarySelectionPaste(enabled: boolean): void {
|
||||
}
|
||||
|
||||
const onAuxClick = (event: MouseEvent): void => {
|
||||
if (event.button === 1 && findEditablePrimarySelectionPasteTarget(event.target)) {
|
||||
suppressEvent(event)
|
||||
if (event.button !== 1) {
|
||||
return
|
||||
}
|
||||
const target = findEditablePrimarySelectionPasteTarget(event.target)
|
||||
if (!target || isLinuxUserAgent()) {
|
||||
return
|
||||
}
|
||||
suppressEvent(event)
|
||||
}
|
||||
|
||||
document.addEventListener('selectionchange', scheduleCapture)
|
||||
|
||||
Reference in New Issue
Block a user