mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-30 07:51:07 -07:00
paste transform followup (#17624)
Co-authored-by: Jack Wotherspoon <jackwoth@google.com>
This commit is contained in:
@@ -57,7 +57,6 @@ import { useUIState } from '../contexts/UIStateContext.js';
|
||||
import { useSettings } from '../contexts/SettingsContext.js';
|
||||
import { StreamingState } from '../types.js';
|
||||
import { useMouseClick } from '../hooks/useMouseClick.js';
|
||||
import { useMouseDoubleClick } from '../hooks/useMouseDoubleClick.js';
|
||||
import { useMouse, type MouseEvent } from '../contexts/MouseContext.js';
|
||||
import { useUIActions } from '../contexts/UIActionsContext.js';
|
||||
import { useAlternateBuffer } from '../hooks/useAlternateBuffer.js';
|
||||
@@ -403,35 +402,54 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
const isAlternateBuffer = useAlternateBuffer();
|
||||
|
||||
// Double-click to expand/collapse paste placeholders
|
||||
useMouseDoubleClick(
|
||||
useMouseClick(
|
||||
innerBoxRef,
|
||||
(_event, relX, relY) => {
|
||||
if (!isAlternateBuffer) return;
|
||||
|
||||
const logicalPos = buffer.getLogicalPositionFromVisual(
|
||||
buffer.visualScrollRow + relY,
|
||||
relX,
|
||||
);
|
||||
if (!logicalPos) return;
|
||||
const visualLine = buffer.viewportVisualLines[relY];
|
||||
if (!visualLine) return;
|
||||
|
||||
// Even if we click past the end of the line, we might want to collapse an expanded paste
|
||||
const isPastEndOfLine = relX >= stringWidth(visualLine);
|
||||
|
||||
const logicalPos = isPastEndOfLine
|
||||
? null
|
||||
: buffer.getLogicalPositionFromVisual(
|
||||
buffer.visualScrollRow + relY,
|
||||
relX,
|
||||
);
|
||||
|
||||
// Check for paste placeholder (collapsed state)
|
||||
const transform = getTransformUnderCursor(
|
||||
logicalPos.row,
|
||||
logicalPos.col,
|
||||
buffer.transformationsByLine,
|
||||
);
|
||||
if (transform?.type === 'paste' && transform.id) {
|
||||
buffer.togglePasteExpansion(transform.id);
|
||||
return;
|
||||
if (logicalPos) {
|
||||
const transform = getTransformUnderCursor(
|
||||
logicalPos.row,
|
||||
logicalPos.col,
|
||||
buffer.transformationsByLine,
|
||||
);
|
||||
if (transform?.type === 'paste' && transform.id) {
|
||||
buffer.togglePasteExpansion(
|
||||
transform.id,
|
||||
logicalPos.row,
|
||||
logicalPos.col,
|
||||
);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for expanded paste region
|
||||
const expandedId = buffer.getExpandedPasteAtLine(logicalPos.row);
|
||||
// If we didn't click a placeholder to expand, check if we are inside or after
|
||||
// an expanded paste region and collapse it.
|
||||
const row = buffer.visualScrollRow + relY;
|
||||
const expandedId = buffer.getExpandedPasteAtLine(row);
|
||||
if (expandedId) {
|
||||
buffer.togglePasteExpansion(expandedId);
|
||||
buffer.togglePasteExpansion(
|
||||
expandedId,
|
||||
row,
|
||||
logicalPos?.col ?? relX, // Fallback to relX if past end of line
|
||||
);
|
||||
}
|
||||
},
|
||||
{ isActive: focus },
|
||||
{ isActive: focus, name: 'double-click' },
|
||||
);
|
||||
|
||||
useMouse(
|
||||
@@ -1228,6 +1246,8 @@ export const InputPrompt: React.FC<InputPromptProps> = ({
|
||||
const absoluteVisualIdx =
|
||||
scrollVisualRow + visualIdxInRenderedSet;
|
||||
const mapEntry = buffer.visualToLogicalMap[absoluteVisualIdx];
|
||||
if (!mapEntry) return null;
|
||||
|
||||
const cursorVisualRow =
|
||||
cursorVisualRowAbsolute - scrollVisualRow;
|
||||
const isOnCursorLine =
|
||||
|
||||
Reference in New Issue
Block a user