Is it possible to kill runmode that's processing?

I built a minimap solution to replace the traditional scrollbar, which is powered by runMode and works great on smallish documents (under 1,000 lines). However, on larger documents (eg 8,000 lines), there’s a noticeable slowdown for say 1 sec (as it’s regenerating the entire minimap content through runMode as you type). This is totally understandable but I need a solution for this.

I think there are 2 good solutions, either:
A. Just run runMode on the parts that are changing and patch the minimap up with those changes. This sounds fine, but of course there’s still a slowdown when you paste in 8,000 lines for instance, before you can start typing.
B. Kill runmode that’s processing currently if the user starts typing in that 1 sec of processing time, giving precedence to the user and the minimap updates in the quiet (non typing) moments.

A or B should work fine, but suspect I need both. However, it is possible to kill runMode easily to stop it in it’s tracks so I can carry out B?

You can not notice events while a script is running, but you could run runMode in smaller increments and use a setTimeout in between to give the browser event loop time to fire events.

That’s a pretty good idea. OK, thanks.