Merge remote-tracking branch 'origin/pr/4339'

This commit is contained in:
Florian Bruhin 2019-02-23 18:55:39 +01:00
commit 9f2073161e
3 changed files with 41 additions and 4 deletions

View File

@ -1236,6 +1236,16 @@ input.insert_mode.plugins:
type: Bool
desc: Switch to insert mode when clicking flash and other plugins.
input.insert_mode.leave_on_load:
default: true
type: Bool
supports_pattern: true
desc: >-
Leave insert mode when starting a new page load.
Patterns may be unreliable on this setting, and they may match the url you
are navigating to, or the URL you are navigating from.
input.links_included_in_focus_chain:
default: true
type: Bool

View File

@ -586,10 +586,20 @@ class TabbedBrowser(QWidget):
@pyqtSlot()
def on_cur_load_started(self):
"""Leave insert/hint mode when loading started."""
modeman.leave(self._win_id, usertypes.KeyMode.insert, 'load started',
maybe=True)
modeman.leave(self._win_id, usertypes.KeyMode.hint, 'load started',
maybe=True)
try:
url = self.current_url()
if not url.isValid():
url = None
except qtutils.QtValueError:
url = None
if config.instance.get('input.insert_mode.leave_on_load',
url=url):
modeman.leave(self._win_id, usertypes.KeyMode.insert,
'load started', maybe=True)
else:
log.modes.debug("Ignoring leave_on_load request due to setting.")
modeman.leave(self._win_id, usertypes.KeyMode.hint,
'load started', maybe=True)
@pyqtSlot(browsertab.AbstractTab, str)
def on_title_changed(self, tab, text):

View File

@ -85,3 +85,20 @@ def test_auto_leave_insert_mode(quteproc):
# Select the disabled input box to leave insert mode
quteproc.send_cmd(':follow-hint s')
quteproc.wait_for(message='Clicked non-editable element!')
@pytest.mark.parametrize('leave_on_load', [True, False])
def test_auto_leave_insert_mode_reload(quteproc, leave_on_load):
url_path = 'data/hello.txt'
quteproc.open_path(url_path)
quteproc.set_setting('input.insert_mode.leave_on_load',
str(leave_on_load).lower())
quteproc.send_cmd(':enter-mode insert')
quteproc.wait_for(message='Entering mode KeyMode.insert (reason: *)')
quteproc.send_cmd(':reload')
if leave_on_load:
quteproc.wait_for(message='Leaving mode KeyMode.insert (reason: *)')
else:
quteproc.wait_for(
message='Ignoring leave_on_load request due to setting.')