From ce1449d21ff8df7a2748d1d62ac9998d0976c3aa Mon Sep 17 00:00:00 2001 From: Dicken Date: Fri, 29 May 2026 13:56:11 +0200 Subject: [PATCH] Code-Schnipsel History: Diff vs. aktuellem Code, Wiederherstellen nur bei Unterschied --- frontend/src/tools/codeschnipsel.jsx | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/frontend/src/tools/codeschnipsel.jsx b/frontend/src/tools/codeschnipsel.jsx index c17a01c..94f5a73 100644 --- a/frontend/src/tools/codeschnipsel.jsx +++ b/frontend/src/tools/codeschnipsel.jsx @@ -148,7 +148,10 @@ function HistoryModal({ snippet, onClose, onRestore, toast }) { const isMob = window.innerWidth < 768; const getOlderCode = (h) => { const idx = history.indexOf(h); - return idx < history.length-1 ? history[idx+1].code : null; + // Newest history entry (idx=0) compares against CURRENT snippet code + if (idx === 0) return snippet.code; + // Older entries compare against the next newer history entry + return history[idx - 1].code; }; return (
{getLangLabel(selected.language)} · {fmtDt(selected.saved_at)} - {showDiff && getOlderCode(selected)===null && (älteste Version)} + {history.indexOf(selected) === history.length-1 && (älteste Version)} - {!snippet.is_shared && ( + {!snippet.is_shared && selected.code !== snippet.code && (