Unload Merge
See original GitHub issuev5.31.0
I have an editor which can switch between a basic codemirror and merge view. When I switch from normal to merge and back to normal it appears to leave the merge view hooks in place. If my single page app stays open long enough it take increasingly long periods of time to load the codemirror editor with new code as the hidden merge view is trying to diff. I reset the generation in the codemirror instance when I load new code but merge is left alone.
My request - is there a way to add support to unload MergeView and its hook/timers?
Background: Merge appears to have hooks like timeouts, events and others. Chrome performance dev tools show merge registered timeout events that run for 1 second per each time I open merge diff with different code as I can see more and more merge.js timers showing up in the performance monitor when I run it (each instance locking the ui for 1s). Refreshing the screen fixes it until I start to use the merge features. Here is my code block for how I start the merge view each time a diff is requested by the user:
var target = document.getElementById("view");
target.innerHTML = ""; // Tried with and without this line
var dv = CodeMirror.MergeView(target, {
value: $scope.codeEditor.linkedDoc({sharedHist:true}),
origLeft: null,
orig: $scope.editorMdl.gitCompare.codeStore.code,
lineNumbers: true,
highlightDifferences: true,
connect: "align",
collapseIdentical: true,
mode: codingcenterService.getLangsMeta($scope.editorMdl.intrchg.lang).language,
theme: "neat"
});
Here is the HTML hosting the segment of the spa display:
<div ng-hide="visi.codeHide" class="erm-full">
<textarea ui-codemirror="codeOption" ng-model="editorMdl.intrchg.fullCode"></textarea>
</div>
<div id=view style="height: 100%;" ng-show="visi.codeHide"></div>
Call stack of the issue: Timer in merge.js line 119 (this calls ~x times depending on on how many times I start diff) Calls merge.js:87 and etc…
Possible fixes in merge.js:
- An “unregister” events function for the materials inside function registerUpdate(dv) on line 83
- A way to call the clearTimeout(debounceChange); as found on line 117
Issue Analytics
- State:
- Created 6 years ago
- Comments:12 (5 by maintainers)
Top GitHub Comments
Yes, that’d be it. You’ll have to unlink the document in the editor that you’re dropping.
In case someone stumbles on this from google, here is a code extract of the solution @marijnh pointed me at: