Skip to content

Commit 3f18d58

Browse files
committed
fix: dirty marker appears after undo operation
1 parent f0c7eb9 commit 3f18d58

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/LiveDevelopment/BrowserScripts/RemoteFunctions.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -137,19 +137,20 @@ function RemoteFunctions(config = {}) {
137137
}
138138

139139
// helper function to check if an element is inside the HEAD tag
140-
// we need this because we don't wanna trigger the element highlights on head tag and its children
140+
// we need this because we don't wanna trigger the element highlights on head tag and its children,
141+
// except for <style> tags which should be allowed
141142
function _isInsideHeadTag(element) {
142143
let parent = element;
143144
while (parent && parent !== window.document) {
144145
if (parent.tagName === "HEAD") {
145-
return true;
146+
// allow <style> tags inside <head>
147+
return element.tagName !== "STYLE";
146148
}
147149
parent = parent.parentElement;
148150
}
149151
return false;
150152
}
151153

152-
153154
// compute the screen offset of an element
154155
function _screenOffset(element) {
155156
var elemBounds = element.getBoundingClientRect(),

src/LiveDevelopment/LivePreviewEdit.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,12 @@ define(function (require, exports, module) {
194194
// this is a quick trick because as the code is changed for that element in the file,
195195
// the live preview for that element gets refreshed and the changes are discarded in the live preview
196196
if(!message.isEditSuccessful) {
197-
editor.replaceRange(text, startPos, endPos);
198-
editor.document._markClean();
197+
editor.document.batchOperation(function () {
198+
editor.replaceRange(text, startPos, endPos);
199+
setTimeout(() => {
200+
editor.undo(); // undo the replaceRange so dirty icon won't appear and no net change in undo history
201+
}, 0);
202+
});
199203
} else {
200204

201205
// if the edit operation was successful, we call a helper function that

0 commit comments

Comments
 (0)