From b0bc7c3d996d25c9fefdfbcba3ca19fa46ad199f Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Thu, 19 Jun 2025 20:17:23 +0000 Subject: Fix flicker issues by ensuring all actively changing content fits in the viewport (#1217) --- .../cli/src/ui/components/shared/text-buffer.ts | 23 +--------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'packages/cli/src/ui/components/shared/text-buffer.ts') diff --git a/packages/cli/src/ui/components/shared/text-buffer.ts b/packages/cli/src/ui/components/shared/text-buffer.ts index 6b025dd5..93364ebe 100644 --- a/packages/cli/src/ui/components/shared/text-buffer.ts +++ b/packages/cli/src/ui/components/shared/text-buffer.ts @@ -12,6 +12,7 @@ import pathMod from 'path'; import { useState, useCallback, useEffect, useMemo } from 'react'; import stringWidth from 'string-width'; import { unescapePath } from '@gemini-cli/core'; +import { toCodePoints, cpLen, cpSlice } from '../../utils/textUtils.js'; export type Direction = | 'left' @@ -69,28 +70,6 @@ function clamp(v: number, min: number, max: number): number { return v < min ? min : v > max ? max : v; } -/* - * ------------------------------------------------------------------------- - * Unicode‑aware helpers (work at the code‑point level rather than UTF‑16 - * code units so that surrogate‑pair emoji count as one "column".) - * ---------------------------------------------------------------------- */ - -export function toCodePoints(str: string): string[] { - // [...str] or Array.from both iterate by UTF‑32 code point, handling - // surrogate pairs correctly. - return Array.from(str); -} - -export function cpLen(str: string): number { - return toCodePoints(str).length; -} - -export function cpSlice(str: string, start: number, end?: number): string { - // Slice by code‑point indices and re‑join. - const arr = toCodePoints(str).slice(start, end); - return arr.join(''); -} - /* ------------------------------------------------------------------------- * Debug helper – enable verbose logging by setting env var TEXTBUFFER_DEBUG=1 * ---------------------------------------------------------------------- */ -- cgit v1.2.3