[foldgutter addon] Recompute fold markers on mode change

Closes https://github.com/codemirror/codemirror5/issues/6968
This commit is contained in:
Marijn Haverbeke 2022-07-28 10:27:42 +02:00
parent 7710c7c8c3
commit 7ac872b0db
1 changed files with 6 additions and 0 deletions

View File

@ -21,6 +21,7 @@
cm.off("fold", onFold);
cm.off("unfold", onFold);
cm.off("swapDoc", onChange);
cm.off("optionChange", optionChange);
}
if (val) {
cm.state.foldGutter = new State(parseOptions(val));
@ -31,6 +32,7 @@
cm.on("fold", onFold);
cm.on("unfold", onFold);
cm.on("swapDoc", onChange);
cm.on("optionChange", optionChange);
}
});
@ -120,6 +122,10 @@
else cm.foldCode(Pos(line, 0), opts);
}
function optionChange(cm, option) {
if (option == "mode") onChange(cm)
}
function onChange(cm) {
var state = cm.state.foldGutter;
if (!state) return;