fix(editor): five locals in stepHistory and MoreTabs, sync tag in tests

This commit is contained in:
bchanot committed 2026-11-14 18:52:41 +01:00
1 parent 08fab77d0e
commit bb35e86dbb
5 files changed
+48 -35

No files matched your search

+11 -2
View File
@@ -69,6 +69,16 @@ export function commit<R>(
return commitBatch(api, [command], accept)
}
/** A step's patch with the finding it brought back, revealed (null when none). */
function withReveal(
patch: Partial<EditorState>,
before: string,
after: string,
): Partial<EditorState> {
const key = appearedFinding(before, after)
return { ...patch, revealed: key ? { key } : null }
}
export function stepHistory(
api: StoreApi,
direction: 'undo' | 'redo',
@@ -82,8 +92,7 @@ export function stepHistory(
const replaced = preview.replaceDocument(step.text)
if (!replaced.ok) return replaced
const patch = replacedPatch(state, step.text, replaced.state, step.history)
const key = appearedFinding(state.documentText, step.text)
api.set({ ...patch, revealed: key ? { key } : null })
api.set(withReveal(patch, state.documentText, step.text))
return { ok: true }
}