Skip to content

Commit

Permalink
protect context upon load
Browse files Browse the repository at this point in the history
  • Loading branch information
jswrenn committed Sep 13, 2021
1 parent be1a95a commit 9032c99
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/web/js/beforePyret.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ $(function() {
CM.clearGutter("help-gutter");
}
}

CM.on("change", function(change) {
function doesNotChangeFirstLine(c) { return c.from.line !== 0; }
if(change.curOp.changeObjs.every(doesNotChangeFirstLine)) { return; }
Expand All @@ -369,6 +370,14 @@ $(function() {
namespacemark = CM.markText({line: 0, ch: 0}, {line: 1, ch: 0}, { attributes: { useline: true }, className: "useline", atomic: true, inclusiveLeft: true, inclusiveRight: false });
}
});

CM.on("swapDoc", function(oldDoc) {
var hasNamespace = firstLineIsNamespace();
if(hasNamespace) {
if(namespacemark) { namespacemark.clear(); }
namespacemark = CM.markText({line: 0, ch: 0}, {line: 1, ch: 0}, { attributes: { useline: true }, className: "useline", atomic: true, inclusiveLeft: true, inclusiveRight: false });
}
});
}
if (useLineNumbers) {
CM.display.wrapper.appendChild(mkWarningUpper()[0]);
Expand Down

0 comments on commit 9032c99

Please sign in to comment.