Skip to content

Commit d7c77ff

Browse files
committed
Sidebar search: Escape key closes search bar if sidebar has focus
1 parent ed4b762 commit d7c77ff

2 files changed

Lines changed: 6 additions & 0 deletions

File tree

gitfourchette/sidebar/sidebar.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ def __init__(self, parent):
8787
makeWidgetShortcut(self, self.onReturnShortcut, "Return", "Enter")
8888
makeWidgetShortcut(self, self.onDeleteShortcut, "Delete")
8989
makeWidgetShortcut(self, self.onRenameShortcut, "F2")
90+
makeWidgetShortcut(self, self.searchBar.hideOrBeep, "Escape")
9091

9192
def filterIndexToNode(self, index: QModelIndex) -> SidebarNode:
9293
assert index.isValid()

test/test_sidebar.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,11 @@ def testSidebarFilter(tempDir, mainWindow):
583583
# "no-parent" doesn't contain "fix", so it must be hidden
584584
assert not sb.indexForRef("refs/heads/no-parent").isValid()
585585

586+
# Hide with keyboard shortcut
587+
sb.setFocus()
588+
QTest.keyClick(sb, Qt.Key.Key_Escape)
589+
assert not searchBar.isVisible()
590+
586591

587592
def testSidebarFilterWithFolders(tempDir, mainWindow):
588593
wd = unpackRepo(tempDir)

0 commit comments

Comments
 (0)