Skip to content

Commit 43b5a59

Browse files
committed
Toggle fold with Enter/Space
1 parent 7b1e7ce commit 43b5a59

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

src/ResultDock.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1100,12 +1100,22 @@ LRESULT CALLBACK ResultDock::sciSubclassProc(HWND hwnd, UINT msg, WPARAM wp, LPA
11001100
::SendMessage(nppData._nppHandle, NPPM_DMMHIDE, 0, (LPARAM)ResultDock::instance()._hDock);
11011101
return TRUE;
11021102

1103-
case WM_KEYDOWN:
1103+
case WM_KEYDOWN: {
11041104
if (wp == VK_DELETE) {
11051105
deleteSelectedItems(hwnd);
1106-
return 0; // eat the key
1106+
return 0;
1107+
}
1108+
if (wp == VK_SPACE || wp == VK_RETURN) {
1109+
Sci_Position pos = ::SendMessage(hwnd, SCI_GETCURRENTPOS, 0, 0);
1110+
int line = (int)::SendMessage(hwnd, SCI_LINEFROMPOSITION, pos, 0);
1111+
int level = (int)::SendMessage(hwnd, SCI_GETFOLDLEVEL, line, 0);
1112+
if (level & SC_FOLDLEVELHEADERFLAG) {
1113+
::SendMessage(hwnd, SCI_TOGGLEFOLD, line, 0);
1114+
return 0;
1115+
}
11071116
}
11081117
break;
1118+
}
11091119

11101120
case WM_NCDESTROY:
11111121
s_prevSciProc = nullptr;
@@ -1693,3 +1703,4 @@ void ResultDock::collapseOldSearches()
16931703
}
16941704
}
16951705
}
1706+

0 commit comments

Comments
 (0)