Skip to content

Commit

Permalink
[Favorite Schemes] Fix TreeView scroll to bottom after scheme checked…
Browse files Browse the repository at this point in the history
…, issue #874.
  • Loading branch information
zufuliu committed Sep 26, 2024
1 parent 0f38f00 commit bf26c21
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/Styles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4698,10 +4698,15 @@ static void Lexer_OnCheckStateChanged(HWND hwndTV, HTREEITEM hFavoriteNode, HTRE
// append node into Favorite Schemes
if (!found) {
constexpr DWORD iconFlags = SHGFI_USEFILEATTRIBUTES | SHGFI_SMALLICON | SHGFI_SYSICONINDEX;
hTreeNode = TreeView_GetLastVisible(hwndTV);
HTREEITEM hChildNode = hTreeNode;
hTreeNode = TreeView_GetNextSibling(hwndTV, hTreeNode);
if (hTreeNode == nullptr) {
hTreeNode = TreeView_GetNextSibling(hwndTV, hParent);
hTreeNode = hTreeNode ? hTreeNode : hChildNode;
}
hParent = Style_AddLexerToTreeView(hwndTV, pLex, iconFlags, hFavoriteNode, hInsertAfter, false);
TreeView_SetCheckState(hwndTV, hParent, TRUE);
// prevent auto scroll
// TODO: prevent auto scroll
TreeView_EnsureVisible(hwndTV, hTreeNode);
}
} else {
Expand Down

0 comments on commit bf26c21

Please sign in to comment.