<p>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.</p>
<p>Perhaps there should be some additional checks, for example make sure to save (not to reset or overwrite):</p>
<ul>
<li>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.</li>
<li>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?</li>
</ul>
<p>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.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1359#issuecomment-271946959">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ7LTEkdWFIgGQsOoHcoqqj2TMwfLks5rRRsmgaJpZM4LghHe">mute the thread</a>.<img alt="" height="1" src="https://github.com/notifications/beacon/ABDrJzOxx9v4uJnGZdCR53MB4WaXBMPMks5rRRsmgaJpZM4LghHe.gif" width="1" /></p>
<div itemscope itemtype="http://schema.org/EmailMessage">
<div itemprop="action" itemscope itemtype="http://schema.org/ViewAction">
  <link itemprop="url" href="https://github.com/geany/geany/issues/1359#issuecomment-271946959"></link>
  <meta itemprop="name" content="View Issue"></meta>
</div>
<meta itemprop="description" content="View this Issue on GitHub"></meta>
</div>

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@Forkest in #1359: 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.\r\n\r\nPerhaps there should be some additional checks, for example make sure to save (not to reset or overwrite):\r\n- 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.\r\n- 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?\r\n\r\nActually, 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."}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1359#issuecomment-271946959"}}}</script>