So… I’m dealing with the infamous “People want to use browser search, but performance of large sets of text is terrible with viewportMargin = Infinity”-issue.
I’ve read quite a bit, and tried out several approaches. Now my latest idea was… What if… I measure the time it takes for CodeMirror to run an update and use that metric to dynamically adapt viewportMargin to a lower value, if the performance is ‘bad’.
But I can’t find an accurate way to measure that that doesn’t involve keeping track of each and every operation, and I was wondering if I didn’t happen to miss some sort of internal value that I could potentially abuse ?
Because I think that would solve the problem. Optimise performance when people edit, but then as things stabilise, move it back to viewportMargin infinity to enable search.
My fallback idea is to just hook into keypress/up events and simply always adapt viewportMargin to a lower value, regardless of the performance, then have a delayed timer reset back to infinity if the last key press has been a while… Anyone tried something similar ?