From 6015091263c3356fb380112360490ed56e0ade5a Mon Sep 17 00:00:00 2001 From: Rayen Sbai Date: Wed, 18 Nov 2026 16:14:01 +0100 Subject: [PATCH] fix: clear removed decorations on Android and iOS whatever the revision Removing the decorations prop sent an empty set with the revision still in decorationsRevision. Once that revision fell out of the 256-edit log, the native view ignored the set and the old marks and gaps stayed. A removed prop now clears at the current revision, as on the web. --- src/CodeEditor.tsx | 3 ++- src/__tests__/CodeEditor.test.tsx | 8 ++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/CodeEditor.tsx b/src/CodeEditor.tsx index c5c2aa9..a25195e 100644 --- a/src/CodeEditor.tsx +++ b/src/CodeEditor.tsx @@ -285,7 +285,8 @@ export const CodeEditor = forwardRef(function Co onEditorBlur={onBlurCallback} onContentSizeChange={onContentSizeChangeCallback} decorations={nativeDecorations} - decorationsRevision={decorationsRevision} + // A removed prop clears for the current text, since a revision older than the edit log is ignored. + decorationsRevision={decorations ? decorationsRevision : -1} onGapLayout={gapsListened.current ? onGapLayoutCallback : undefined} hybridRef={hybridRef} /> diff --git a/src/__tests__/CodeEditor.test.tsx b/src/__tests__/CodeEditor.test.tsx index 1456d79..933e200 100644 --- a/src/__tests__/CodeEditor.test.tsx +++ b/src/__tests__/CodeEditor.test.tsx @@ -389,6 +389,14 @@ describe('CodeEditor', () => { expect(empty.decorationsRevision).toBe(-1); }); + it('clears removed decorations for the current text, whatever decorationsRevision says', async () => { + const decorations: Decoration[] = [{ kind: 'gap', line: 1, rows: 2 }]; + const api = await render(); + await api.rerender(); + expect(host(api).decorations).toEqual([]); + expect(host(api).decorationsRevision).toBe(-1); + }); + it('wires onGapLayout once a handler was set', async () => { const api = await render(); expect(host(api).onGapLayout).toBeUndefined();