Add setting to avoid leaving insert mode on load_started

It looks like load_started can be emitted for a lot of things, such as
an anchor change, and some people may not want to leave insert mode on
reload anyway.
This commit is contained in:
Jay Kamat 2018-10-14 23:51:42 -07:00
parent 87dffa5afc
commit 975508f4ea
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
3 changed files with 28 additions and 4 deletions

View File

@ -1270,6 +1270,11 @@ 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
desc: Leave insert mode when starting a new page load.
input.links_included_in_focus_chain:
default: true
type: Bool

View File

@ -584,10 +584,13 @@ 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)
if config.val.input.insert_mode.leave_on_load:
modeman.leave(self._win_id, usertypes.KeyMode.insert,
'load started', maybe=True)
modeman.leave(self._win_id, usertypes.KeyMode.hint,
'load started', maybe=True)
else:
log.modes.debug("Ignoring leave_on_load request due to setting.")
@pyqtSlot(browsertab.AbstractTab, str)
def on_title_changed(self, tab, text):

View File

@ -85,3 +85,19 @@ 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.')