 fetchHistory = (state) ->
   cache = historyCache[state.position]
   if cache
-    console.log(state.position)
-    console.log(cache)
     replaceDocument cache.body, cache.title
     triggerPageChange
+    window.scrollTo(cache.scrollLeft,cache.scrollTop)
   else
     fetchReplacement document.location.href
 

visit = (url) ->
  if browserSupportsPushState? and document.location.href != url
    rememberInitialPage()
    reflectNewUrl url
    fetchReplacement url
  else

  window.history.replaceState { turbolinks: true, position: window.history.length - 1}, "", document.location.href
  historyCache[window.history.state.position] = url: document.location.href, body: document.body, title: document.title
  initialized

saveScrollOffset = ->
  cache = historyCache[window.history.state.position]
  cache.scrollTop = window.pageYOffset
  cache.scrollLeft = window.pageXOffset



fetchReplacement = (url) ->
