Refocus command prompt after a new tab is opened when in command mode

This commit is contained in:
Jay Kamat 2018-05-11 08:45:43 -07:00
parent 95093b82c9
commit 71d55e9213
No known key found for this signature in database
GPG Key ID: 5D2E399600F4F7B5
2 changed files with 26 additions and 1 deletions

View File

@ -22,7 +22,7 @@
import functools import functools
import attr import attr
from PyQt5.QtWidgets import QSizePolicy, QWidget from PyQt5.QtWidgets import QSizePolicy, QWidget, QApplication
from PyQt5.QtCore import pyqtSignal, pyqtSlot, QTimer, QUrl from PyQt5.QtCore import pyqtSignal, pyqtSlot, QTimer, QUrl
from PyQt5.QtGui import QIcon from PyQt5.QtGui import QIcon
@ -458,6 +458,8 @@ class TabbedBrowser(QWidget):
"related {}, idx {}".format( "related {}, idx {}".format(
url, background, related, idx)) url, background, related, idx))
prev_focus = QApplication.focusWidget()
if (config.val.tabs.tabs_are_windows and self.widget.count() > 0 and if (config.val.tabs.tabs_are_windows and self.widget.count() > 0 and
not ignore_tabs_are_windows): not ignore_tabs_are_windows):
window = mainwindow.MainWindow(private=self.private) window = mainwindow.MainWindow(private=self.private)
@ -494,6 +496,13 @@ class TabbedBrowser(QWidget):
# WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076 # WORKAROUND for https://bugreports.qt.io/browse/QTBUG-68076
tab.setFocus() tab.setFocus()
mode = modeman.instance(self._win_id).mode
if mode in [usertypes.KeyMode.command, usertypes.KeyMode.prompt,
usertypes.KeyMode.yesno]:
# If we were in a command prompt, restore old focus
# The above commands need to be run to switch tabs
prev_focus.setFocus()
tab.show() tab.show()
self.new_tab.emit(tab, idx) self.new_tab.emit(tab, idx)
return tab return tab

View File

@ -1272,3 +1272,19 @@ Feature: Tab management
And I run :enter-mode insert And I run :enter-mode insert
And I run :fake-key -g new And I run :fake-key -g new
Then the javascript message "contents: existingnew" should be logged Then the javascript message "contents: existingnew" should be logged
Scenario: Focused prompt after opening link in bg
When I open data/hints/link_input.html
When I run :set-cmd-text -s :message-info
And I open data/hello.txt in a new background tab
And I run :fake-key -g hello-world
And I run :command-accept
Then the message "hello-world" should be shown
Scenario: Focused prompt after opening link in fg
When I open data/hints/link_input.html
When I run :set-cmd-text -s :message-info
And I open data/hello.txt in a new tab
And I run :fake-key -g hello-world
And I run :command-accept
Then the message "hello-world" should be shown