diff --git a/qutebrowser/browser/webview.py b/qutebrowser/browser/webview.py index 2512160e3..b05fc84ea 100644 --- a/qutebrowser/browser/webview.py +++ b/qutebrowser/browser/webview.py @@ -119,6 +119,7 @@ class WebView(QWebView): self.destroyed.connect(functools.partial( cfg.changed.disconnect, self.init_neighborlist)) self.cur_url = QUrl() + self._orig_url = QUrl() self.progress = 0 self.registry = objreg.ObjectRegistry() self.tab_id = next(tab_id_gen) @@ -148,8 +149,13 @@ class WebView(QWebView): @pyqtSlot() def on_initial_layout_completed(self): """Add url to history now that we have displayed something.""" - objreg.get('web-history').add_url( - self.url().toDisplayString(), self.title()) + history = objreg.get('web-history') + if not self._orig_url.matches(self.cur_url, + QUrl.UrlFormattingOption(0)): + # If the url of the page is different than the url of the link + # originally clicked, save them both. + history.add_url(self._orig_url.toDisplayString()) + history.add_url(self.cur_url.toDisplayString(), self.title()) def _init_page(self): """Initialize the QWebPage used by this view.""" @@ -190,6 +196,8 @@ class WebView(QWebView): log.webview.debug("load status for {}: {}".format(repr(self), val)) self.load_status = val self.load_status_changed.emit(val.name) + if val == LoadStatus.loading: + self._orig_url = self.cur_url def _set_bg_color(self): """Set the webpage background color as configured."""