Fix caret being cleared when leaving any mode

This commit is contained in:
Jay Kamat 2018-02-12 22:51:04 -05:00
parent 0fae611021
commit 6eeacfe82b
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
3 changed files with 7 additions and 4 deletions

View File

@ -342,7 +342,7 @@ class AbstractCaret(QObject):
def _on_mode_entered(self, mode):
raise NotImplementedError
def _on_mode_left(self):
def _on_mode_left(self, mode):
raise NotImplementedError
def move_to_next_line(self, count=1):

View File

@ -223,7 +223,10 @@ class WebEngineCaret(browsertab.AbstractCaret):
self._js_call('setInitialCursor')
@pyqtSlot(usertypes.KeyMode)
def _on_mode_left(self):
def _on_mode_left(self, mode):
if mode != usertypes.KeyMode.caret:
return
self.drop_selection()
self._js_call('disableCaret')

View File

@ -205,8 +205,8 @@ class WebKitCaret(browsertab.AbstractCaret):
self._widget.page().currentFrame().evaluateJavaScript(
utils.read_file('javascript/position_caret.js'))
@pyqtSlot()
def _on_mode_left(self):
@pyqtSlot(usertypes.KeyMode)
def _on_mode_left(self, _mode):
settings = self._widget.settings()
if settings.testAttribute(QWebSettings.CaretBrowsingEnabled):
if self.selection_enabled and self._widget.hasSelection():