Skip to content

armgit / codex

Public Imported from GitHub
0

Lightweight coding agent that runs in your terminal

Rust

feat: enhance toCodePoints to prevent potential unicode 14 errors (#615)

Luci6d68a90064f5
diff --git a/codex-cli/src/text-buffer.ts b/codex-cli/src/text-buffer.ts
index fe4e2a4759..150feec9ca 100644
--- a/codex-cli/src/text-buffer.ts
+++ b/codex-cli/src/text-buffer.ts
@@ -34,6 +34,10 @@ function clamp(v: number, min: number, max: number): number {
* ---------------------------------------------------------------------- */
function toCodePoints(str: string): Array<string> {
+ if (typeof Intl !== "undefined" && "Segmenter" in Intl) {
+ const seg = new Intl.Segmenter();
+ return [...seg.segment(str)].map((seg) => seg.segment);
+ }
// [...str] or Array.from both iterate by UTF‑32 code point, handling
// surrogate pairs correctly.
return Array.from(str);