From c4da7f1f2fce58bc357084a960b1c42bfc11be9f Mon Sep 17 00:00:00 2001 From: lucaronin Date: Tue, 21 Apr 2026 18:54:02 +0200 Subject: [PATCH] fix: narrow raw mode sync override --- src/components/useRawModeWithFlush.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/components/useRawModeWithFlush.ts b/src/components/useRawModeWithFlush.ts index 4ef7bb42..b6d46e7a 100644 --- a/src/components/useRawModeWithFlush.ts +++ b/src/components/useRawModeWithFlush.ts @@ -246,17 +246,21 @@ function useSyncRawModeContentOverride({ rawSourceContentRef: React.MutableRefObject setRawModeContentOverride: React.Dispatch> }) { - const syncRawModeContentOverride = (current: PendingRawExitContent | null) => { + const syncRawModeContentOverride = ( + current: PendingRawExitContent | null, + nextContent: string, + ) => { if (!current) return current - if (current.path !== activeTabPath || current.content === activeTabContent) return current - return { path: activeTabPath, content: activeTabContent } + if (current.path !== activeTabPath || current.content === nextContent) return current + return { path: activeTabPath, content: nextContent } } useLayoutEffect(() => { if (!activeTabPath || activeTabContent === null) return if (rawSourceContentRef.current === null || activeTabContent === rawSourceContentRef.current) return + const nextContent = activeTabContent - setRawModeContentOverride(syncRawModeContentOverride) + setRawModeContentOverride((current) => syncRawModeContentOverride(current, nextContent)) }, [activeTabContent, activeTabPath, rawSourceContentRef, setRawModeContentOverride]) }