Or it may be implemented without a timer: simply save each caret movement, but if the latest element in the caret history stack was added, say, less than a second ago, overwrite it (except for some cases, listed below). You don't need to keep the time for each position in the stack, the latest addition time variable is enough. In fact it shouldn't be real time, but monotonic time.
Perhaps there should be some additional checks, for example make sure to save (not to reset or overwrite): - when the previous caret movement was caused by an edit and this one is caused by user movement, so an edit is never missing in history. - before any special/external caret movement: before going to marker, before code navigation, before Ctrl+Home/End. Is there an easy way to hook somewhere in the API in a general way?
Actually, I see that there is already Code Navigation History, it should save the location before code navigation, maybe it can be merged with the new system, or even the new system can be built atop of it.