From: Yihui Xie Date: Tue, 22 Aug 2017 15:29:09 +0000 (-0500) Subject: livereload: Maintain the scroll position if possible X-Git-Tag: v0.27~16 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7231d5a829f8d97336a2120afde1260db6ee6541;p=brevno-suite%2Fhugo livereload: Maintain the scroll position if possible This fixes #3824: when the current pathname is the same as the one to be loaded, just call location.reload() so that the current scroll position can be preserved, instead of assigning to location.href, which will cause the scroll position to be lost. --- diff --git a/livereload/livereload.go b/livereload/livereload.go index a5da891f..74702175 100644 --- a/livereload/livereload.go +++ b/livereload/livereload.go @@ -122,7 +122,12 @@ HugoReload.prototype.reload = function(path, options) { } path = path.substring(prefix.length); - window.location.href = path; + + if (window.location.pathname === path) { + window.location.reload(); + } else { + window.location.href = path; + } return true; };