Get rid of end-of-doc-workaround in caret browsing

In Qt < 5.10 (and also sometimes on Windows), we get extra spaces or newlines
when moving to the end of the document. However, this only happens *sometimes*,
and manual testing confirms that with the current workaround, we actually lose
the last char in the selection.

I'm not sure what's happening there, but instead of making things worse with
the workaround, let's just be a bit less strict with the checking there and
accept both variants... This seems like some Chromium bug we can't do much
about.
This commit is contained in:
Florian Bruhin 2018-09-15 20:39:35 +02:00
parent e47bf7a137
commit abff44def6
3 changed files with 7 additions and 20 deletions

View File

@ -238,11 +238,8 @@ class WebEngineCaret(browsertab.AbstractCaret):
flags = set()
if qtutils.version_check('5.7.1', compiled=False):
flags.add('filter-prefix')
if not qtutils.version_check('5.10', compiled=False):
flags.add('end-of-doc-workaround')
if utils.is_windows:
flags.add('windows')
flags.add('end-of-doc-workaround')
return list(flags)
@pyqtSlot(usertypes.KeyMode)

View File

@ -793,13 +793,6 @@ window._qutebrowser.caret = (function() {
*/
CaretBrowsing.needsFilterPrefix = null;
/**
* Whether we're running on Qt < 5.10.
* There, we need some additional movement workarounds.
* @type {boolean}
*/
CaretBrowsing.needsEndOfDocWorkaround = null;
/**
* Check if a node is a control that normally allows the user to interact
* with it using arrow keys. We won't override the arrow keys when such a
@ -1333,8 +1326,6 @@ window._qutebrowser.caret = (function() {
funcs.setFlags = (flags) => {
CaretBrowsing.isWindows = flags.includes("windows");
CaretBrowsing.needsFilterPrefix = flags.includes("filter-prefix");
CaretBrowsing.needsEndOfDocWorkaround =
flags.includes("end-of-doc-workaround");
};
funcs.disableCaret = () => {
@ -1418,9 +1409,6 @@ window._qutebrowser.caret = (function() {
funcs.moveToEndOfDocument = () => {
CaretBrowsing.move("forward", "documentboundary");
if (CaretBrowsing.needsEndOfDocWorkaround) {
CaretBrowsing.move("left", "character");
}
CaretBrowsing.finishMove();
};

View File

@ -47,7 +47,7 @@ class Selection:
self._caret = caret
self._callback_checker = utils.CallbackChecker(qtbot)
def check(self, expected):
def check(self, expected, *, strip=False):
"""Check whether we got the expected selection.
Since (especially on Windows) the selection is empty if we're too
@ -60,13 +60,15 @@ class Selection:
selection = blocker.args[0]
if selection:
if strip:
selection = selection.strip()
assert selection == expected
return
self._qtbot.wait(50)
def check_multiline(self, expected):
self.check(textwrap.dedent(expected).strip())
def check_multiline(self, expected, *, strip=False):
self.check(textwrap.dedent(expected).strip(), strip=strip)
def toggle(self):
with self._qtbot.wait_signal(self._caret.selection_toggled):
@ -89,7 +91,7 @@ class TestDocument:
four five six
vier fünf sechs
""")
""", strip=True)
def test_moving_to_end_and_start(self, caret, selection):
caret.move_to_end_of_document()
@ -108,7 +110,7 @@ class TestDocument:
four five six
vier fünf sechs
""")
""", strip=True)
class TestBlock: