Always leave hint/caret mode when switching tabs

See #3323
This commit is contained in:
Florian Bruhin 2017-11-22 08:46:15 +01:00
parent 401a37bf4b
commit 2581be051f
3 changed files with 10 additions and 7 deletions

View File

@ -239,7 +239,7 @@
|<<tabs.new_position.related,tabs.new_position.related>>|Position of new tabs opened from another tab.
|<<tabs.new_position.unrelated,tabs.new_position.unrelated>>|Position of new tabs which aren't opened from another tab.
|<<tabs.padding,tabs.padding>>|Padding (in pixels) around text for tabs.
|<<tabs.persist_mode_on_change,tabs.persist_mode_on_change>>|When switching tabs, retain the current mode.
|<<tabs.persist_mode_on_change,tabs.persist_mode_on_change>>|When switching tabs, stay in insert/passthrough mode.
|<<tabs.pinned.shrink,tabs.pinned.shrink>>|Shrink pinned tabs down to their contents.
|<<tabs.position,tabs.position>>|Position of the tab bar.
|<<tabs.select_on_remove,tabs.select_on_remove>>|Which tab to select when the focused tab is removed.
@ -2802,7 +2802,7 @@ Default:
[[tabs.persist_mode_on_change]]
=== tabs.persist_mode_on_change
When switching tabs, retain the current mode.
When switching tabs, stay in insert/passthrough mode.
Type: <<types,Bool>>

View File

@ -1238,7 +1238,7 @@ tabs.padding:
tabs.persist_mode_on_change:
default: false
type: Bool
desc: When switching tabs, retain the current mode.
desc: When switching tabs, stay in insert/passthrough mode.
tabs.position:
default: top

View File

@ -652,11 +652,14 @@ class TabbedBrowser(tabwidget.TabWidget):
log.modes.debug("Current tab changed, focusing {!r}".format(tab))
tab.setFocus()
modes_to_leave = [usertypes.KeyMode.hint, usertypes.KeyMode.caret]
if not config.val.tabs.persist_mode_on_change:
for mode in [usertypes.KeyMode.hint, usertypes.KeyMode.insert,
usertypes.KeyMode.caret,
usertypes.KeyMode.passthrough]:
modeman.leave(self._win_id, mode, 'tab changed', maybe=True)
modes_to_leave += [usertypes.KeyMode.insert,
usertypes.KeyMode.passthrough]
for mode in modes_to_leave:
modeman.leave(self._win_id, mode, 'tab changed', maybe=True)
if self._now_focused is not None:
objreg.register('last-focused-tab', self._now_focused, update=True,
scope='window', window=self._win_id)