From 890e26b2b5fe39dd68f0117ab5d75103c2622d3e Mon Sep 17 00:00:00 2001 From: Artur Shaikhullin Date: Wed, 6 Dec 2017 13:58:23 +0600 Subject: [PATCH] Additional fixes --- qutebrowser/browser/commands.py | 3 +++ qutebrowser/browser/webengine/webenginetab.py | 2 +- qutebrowser/browser/webkit/webkittab.py | 3 ++- qutebrowser/javascript/webengine_caret.js | 1 + tests/end2end/features/test_caret_bdd.py | 2 +- 5 files changed, 8 insertions(+), 3 deletions(-) diff --git a/qutebrowser/browser/commands.py b/qutebrowser/browser/commands.py index 476bf1693..09da845f0 100644 --- a/qutebrowser/browser/commands.py +++ b/qutebrowser/browser/commands.py @@ -65,6 +65,8 @@ class CommandDispatcher: def __init__(self, win_id, tabbed_browser): self._win_id = win_id self._tabbed_browser = tabbed_browser + self.yank_object = {} + self.userscript_object = {} def __repr__(self): return utils.get_repr(self) @@ -883,6 +885,7 @@ class CommandDispatcher: message.info("{} {} yanked to {}".format( len(s), "char" if len(s) == 1 else "chars", target)) if not self.yank_object['keep']: + log.procs.debug(self.yank_object['keep']) modeman.leave(self._win_id, KeyMode.caret, "yank selected", maybe=True) self.yank_object = None diff --git a/qutebrowser/browser/webengine/webenginetab.py b/qutebrowser/browser/webengine/webenginetab.py index 8f71d5b1c..977e3a2c1 100644 --- a/qutebrowser/browser/webengine/webenginetab.py +++ b/qutebrowser/browser/webengine/webenginetab.py @@ -184,6 +184,7 @@ class WebEngineCaret(browsertab.AbstractCaret): @pyqtSlot(usertypes.KeyMode) def _on_mode_left(self): + self.drop_selection() self._tab.run_js_async( javascript.assemble('caret', 'toggle')) @@ -284,7 +285,6 @@ class WebEngineCaret(browsertab.AbstractCaret): # https://bugreports.qt.io/browse/QTBUG-53134 self._tab.run_js_async( 'window.getSelection().toString()', callback) - self.drop_selection() def _follow_selected_cb(self, js_elem, tab=False): """Callback for javascript which clicks the selected element. diff --git a/qutebrowser/browser/webkit/webkittab.py b/qutebrowser/browser/webkit/webkittab.py index a1aeee698..fa77627f9 100644 --- a/qutebrowser/browser/webkit/webkittab.py +++ b/qutebrowser/browser/webkit/webkittab.py @@ -338,7 +338,8 @@ class WebKitCaret(browsertab.AbstractCaret): def selection(self, html=False, callback=False): if html: callback(self._widget.selectedHtml()) - callback(self._widget.selectedText()) + else: + callback(self._widget.selectedText()) def follow_selected(self, *, tab=False): if not self.has_selection(): diff --git a/qutebrowser/javascript/webengine_caret.js b/qutebrowser/javascript/webengine_caret.js index e6f71d44f..d4d7e5a96 100644 --- a/qutebrowser/javascript/webengine_caret.js +++ b/qutebrowser/javascript/webengine_caret.js @@ -1051,6 +1051,7 @@ window._qutebrowser.caret = (function() { // eslint-disable-line max-statements, funcs.moveToEndOfDocument = () => { CaretBrowsing.move("forward", "documentboundary"); + window.scrollTo(0, document.body.scrollHeight); }; funcs.dropSelection = () => { diff --git a/tests/end2end/features/test_caret_bdd.py b/tests/end2end/features/test_caret_bdd.py index 97b18434b..ee6cda82c 100644 --- a/tests/end2end/features/test_caret_bdd.py +++ b/tests/end2end/features/test_caret_bdd.py @@ -17,10 +17,10 @@ # You should have received a copy of the GNU General Public License # along with qutebrowser. If not, see . +# pylint: disable=unused-import import pytest import pytest_bdd as bdd -# pylint: disable=unused-import from end2end.features.test_yankpaste_bdd import init_fake_clipboard bdd.scenarios('caret.feature')