Handle invalid URLs in :jump-mark

This commit is contained in:
Florian Bruhin 2016-06-30 20:59:18 +02:00
parent b527cf53d2
commit 4ae3df62c5
2 changed files with 26 additions and 11 deletions

View File

@ -30,6 +30,12 @@ Changed
`gg` can be used with a count.
- Aliases can now use `;;` to have an alias which executed multiple commands.
Fixed
-----
- Using `:jump-mark` (e.g. `''`) when the current URL is invalid doesn't crash
anymore.
v0.7.0
------

View File

@ -668,21 +668,30 @@ class TabbedBrowser(tabwidget.TabWidget):
Args:
key: mark identifier; capital indicates a global mark
"""
# consider urls that differ only in fragment to be identical
urlkey = self.current_url().adjusted(QUrl.RemoveFragment)
try:
# consider urls that differ only in fragment to be identical
urlkey = self.current_url().adjusted(QUrl.RemoveFragment)
except qtutils.QtValueError:
urlkey = None
frame = self.currentWidget().page().currentFrame()
if key.isupper() and key in self._global_marks:
point, url = self._global_marks[key]
if key.isupper():
if key in self._global_marks:
point, url = self._global_marks[key]
@pyqtSlot(bool)
def callback(ok):
if ok:
self.cur_load_finished.disconnect(callback)
frame.setScrollPosition(point)
@pyqtSlot(bool)
def callback(ok):
if ok:
self.cur_load_finished.disconnect(callback)
frame.setScrollPosition(point)
self.openurl(url, newtab=False)
self.cur_load_finished.connect(callback)
self.openurl(url, newtab=False)
self.cur_load_finished.connect(callback)
else:
message.error(self._win_id, "Mark {} is not set".format(key))
elif urlkey is None:
message.error(self._win_id, "Current URL is invalid!")
elif urlkey in self._local_marks and key in self._local_marks[urlkey]:
point = self._local_marks[urlkey][key]