Skip to content

Commit 69c6010

Browse files
authored
Update live-view.js
1 parent 3b760f3 commit 69c6010

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

live-view/live-view.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,15 @@ async function setupLiveView() {
104104
// show file content in codeit
105105
try {
106106

107-
cd.textContent = decodeUnicode(selectedFile.content);
107+
const fileContent = decodeUnicode(selectedFile.content);
108+
109+
// compare current code with new code
110+
if (hashCode(cd.textContent) !== hashCode(fileContent)) {
111+
112+
// if code is different, swap it
113+
cd.textContent = fileContent;
114+
115+
}
108116

109117
// change codeit lang
110118
cd.lang = selectedFile.lang;

0 commit comments

Comments
 (0)