mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-24 22:55:13 +00:00
Run formatter and fix lint issue.
This commit is contained in:
@@ -8,7 +8,7 @@ import React, { Fragment, useEffect, useId } from 'react';
|
|||||||
import { Box, Text } from 'ink';
|
import { Box, Text } from 'ink';
|
||||||
import stringWidth from 'string-width';
|
import stringWidth from 'string-width';
|
||||||
import { Colors } from '../../colors.js';
|
import { Colors } from '../../colors.js';
|
||||||
import { toCodePoints, cpSlice } from '../../utils/textUtils.js';
|
import { toCodePoints } from '../../utils/textUtils.js';
|
||||||
import { useOverflowActions } from '../../contexts/OverflowContext.js';
|
import { useOverflowActions } from '../../contexts/OverflowContext.js';
|
||||||
|
|
||||||
let enableDebugLog = false;
|
let enableDebugLog = false;
|
||||||
@@ -434,12 +434,12 @@ function layoutInkElementAsStyledText(
|
|||||||
if (availableWidth < 1) {
|
if (availableWidth < 1) {
|
||||||
// No room to render the wrapping segments. Truncate the non-wrapping
|
// No room to render the wrapping segments. Truncate the non-wrapping
|
||||||
// content and append an ellipsis so the line always fits within maxWidth.
|
// content and append an ellipsis so the line always fits within maxWidth.
|
||||||
|
|
||||||
// Handle line breaks in non-wrapping content when truncating
|
// Handle line breaks in non-wrapping content when truncating
|
||||||
const lines: StyledText[][] = [];
|
const lines: StyledText[][] = [];
|
||||||
let currentLine: StyledText[] = [];
|
let currentLine: StyledText[] = [];
|
||||||
let currentLineWidth = 0;
|
let currentLineWidth = 0;
|
||||||
|
|
||||||
for (const segment of nonWrappingContent) {
|
for (const segment of nonWrappingContent) {
|
||||||
const textLines = segment.text.split('\n');
|
const textLines = segment.text.split('\n');
|
||||||
textLines.forEach((text, index) => {
|
textLines.forEach((text, index) => {
|
||||||
@@ -449,10 +449,10 @@ function layoutInkElementAsStyledText(
|
|||||||
currentLine = [];
|
currentLine = [];
|
||||||
currentLineWidth = 0;
|
currentLineWidth = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text) {
|
if (text) {
|
||||||
const textWidth = stringWidth(text);
|
const textWidth = stringWidth(text);
|
||||||
|
|
||||||
// When there's no room for wrapping content, be very conservative
|
// When there's no room for wrapping content, be very conservative
|
||||||
// For lines after the first line break, show only ellipsis if the text would be truncated
|
// For lines after the first line break, show only ellipsis if the text would be truncated
|
||||||
if (index > 0 && textWidth > 0) {
|
if (index > 0 && textWidth > 0) {
|
||||||
@@ -462,7 +462,7 @@ function layoutInkElementAsStyledText(
|
|||||||
} else {
|
} else {
|
||||||
// This is the first line or a continuation, try to fit what we can
|
// This is the first line or a continuation, try to fit what we can
|
||||||
const maxContentWidth = Math.max(0, maxWidth - stringWidth('…'));
|
const maxContentWidth = Math.max(0, maxWidth - stringWidth('…'));
|
||||||
|
|
||||||
if (textWidth <= maxContentWidth && currentLineWidth === 0) {
|
if (textWidth <= maxContentWidth && currentLineWidth === 0) {
|
||||||
// Text fits completely on this line
|
// Text fits completely on this line
|
||||||
currentLine.push({ text, props: segment.props });
|
currentLine.push({ text, props: segment.props });
|
||||||
@@ -472,7 +472,7 @@ function layoutInkElementAsStyledText(
|
|||||||
const codePoints = toCodePoints(text);
|
const codePoints = toCodePoints(text);
|
||||||
let truncatedWidth = currentLineWidth;
|
let truncatedWidth = currentLineWidth;
|
||||||
let sliceEndIndex = 0;
|
let sliceEndIndex = 0;
|
||||||
|
|
||||||
for (const char of codePoints) {
|
for (const char of codePoints) {
|
||||||
const charWidth = stringWidth(char);
|
const charWidth = stringWidth(char);
|
||||||
if (truncatedWidth + charWidth > maxContentWidth) {
|
if (truncatedWidth + charWidth > maxContentWidth) {
|
||||||
@@ -481,7 +481,7 @@ function layoutInkElementAsStyledText(
|
|||||||
truncatedWidth += charWidth;
|
truncatedWidth += charWidth;
|
||||||
sliceEndIndex++;
|
sliceEndIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
const slice = codePoints.slice(0, sliceEndIndex).join('');
|
const slice = codePoints.slice(0, sliceEndIndex).join('');
|
||||||
if (slice) {
|
if (slice) {
|
||||||
currentLine.push({ text: slice, props: segment.props });
|
currentLine.push({ text: slice, props: segment.props });
|
||||||
@@ -493,7 +493,7 @@ function layoutInkElementAsStyledText(
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add the last line if it has content or if the last segment ended with \n
|
// Add the last line if it has content or if the last segment ended with \n
|
||||||
if (
|
if (
|
||||||
currentLine.length > 0 ||
|
currentLine.length > 0 ||
|
||||||
@@ -502,12 +502,12 @@ function layoutInkElementAsStyledText(
|
|||||||
) {
|
) {
|
||||||
lines.push(currentLine);
|
lines.push(currentLine);
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we don't have any lines yet, add an ellipsis line
|
// If we don't have any lines yet, add an ellipsis line
|
||||||
if (lines.length === 0) {
|
if (lines.length === 0) {
|
||||||
lines.push([{ text: '…', props: {} }]);
|
lines.push([{ text: '…', props: {} }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const line of lines) {
|
for (const line of lines) {
|
||||||
output.push(line);
|
output.push(line);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user