mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-03 16:34:31 -07:00
paste transform followup (#17624)
Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
This commit is contained in:
@@ -22,6 +22,8 @@ import {
|
||||
type MouseEvent,
|
||||
type MouseEventName,
|
||||
type MouseHandler,
|
||||
DOUBLE_CLICK_THRESHOLD_MS,
|
||||
DOUBLE_CLICK_DISTANCE_TOLERANCE,
|
||||
} from '../utils/mouse.js';
|
||||
|
||||
export type { MouseEvent, MouseEventName, MouseHandler };
|
||||
@@ -67,6 +69,11 @@ export function MouseProvider({
|
||||
}) {
|
||||
const { stdin } = useStdin();
|
||||
const subscribers = useRef<Set<MouseHandler>>(new Set()).current;
|
||||
const lastClickRef = useRef<{
|
||||
time: number;
|
||||
col: number;
|
||||
row: number;
|
||||
} | null>(null);
|
||||
|
||||
const subscribe = useCallback(
|
||||
(handler: MouseHandler) => {
|
||||
@@ -96,6 +103,30 @@ export function MouseProvider({
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (event.name === 'left-press') {
|
||||
const now = Date.now();
|
||||
const lastClick = lastClickRef.current;
|
||||
if (
|
||||
lastClick &&
|
||||
now - lastClick.time < DOUBLE_CLICK_THRESHOLD_MS &&
|
||||
Math.abs(event.col - lastClick.col) <=
|
||||
DOUBLE_CLICK_DISTANCE_TOLERANCE &&
|
||||
Math.abs(event.row - lastClick.row) <= DOUBLE_CLICK_DISTANCE_TOLERANCE
|
||||
) {
|
||||
const doubleClickEvent: MouseEvent = {
|
||||
...event,
|
||||
name: 'double-click',
|
||||
};
|
||||
for (const handler of subscribers) {
|
||||
handler(doubleClickEvent);
|
||||
}
|
||||
lastClickRef.current = null;
|
||||
} else {
|
||||
lastClickRef.current = { time: now, col: event.col, row: event.row };
|
||||
}
|
||||
}
|
||||
|
||||
if (
|
||||
!handled &&
|
||||
event.name === 'move' &&
|
||||
|
||||
Reference in New Issue
Block a user