From f45f8faee04b4bf70c3f6eaf5ba37321b69a2c8b Mon Sep 17 00:00:00 2001 From: Hailey Date: Tue, 23 Apr 2024 19:45:05 -0700 Subject: [PATCH] test logs --- src/view/com/composer/text-input/TextInput.web.tsx | 5 +++++ src/view/com/composer/text-input/text-input-util.ts | 9 +++++++++ 2 files changed, 14 insertions(+) diff --git a/src/view/com/composer/text-input/TextInput.web.tsx b/src/view/com/composer/text-input/TextInput.web.tsx index 565f5b2c07..64abeea37d 100644 --- a/src/view/com/composer/text-input/TextInput.web.tsx +++ b/src/view/com/composer/text-input/TextInput.web.tsx @@ -192,6 +192,11 @@ export const TextInput = React.forwardRef(function TextInputImpl( newRt.detectFacetsWithoutResolution() setRichText(newRt) + console.log({ + utf8Length: newRt.length, + utf16Length: newText.length, + }) + if (newRt.facets) { for (const facet of newRt.facets) { for (const feature of facet.features) { diff --git a/src/view/com/composer/text-input/text-input-util.ts b/src/view/com/composer/text-input/text-input-util.ts index 7444f55360..0cf68c5815 100644 --- a/src/view/com/composer/text-input/text-input-util.ts +++ b/src/view/com/composer/text-input/text-input-util.ts @@ -15,6 +15,10 @@ export function addLinkCardIfNecessary({ prevAddedLinks: Set byteEnd: number }) { + console.log({ + byteIndex: byteEnd, + }) + const utf16Index = utf8IndexToUtf16Index(newText, byteEnd) // Because we always trim the whitespace at the end of the text newText = newText + ' ' @@ -28,6 +32,11 @@ export function addLinkCardIfNecessary({ toAdd = 1 } + console.log({ + utf8Index: byteEnd, + utf16Index: utf16Index, + }) + if (!mayBePaste && utf16Index + toAdd !== cursorLocation) { return }