From 7ab651f0785d1fa7cffc5f3e31b0bc4f4af15e4e Mon Sep 17 00:00:00 2001 From: Mike Williams Date: Thu, 19 Jan 2023 11:46:13 -0500 Subject: [PATCH] Common: make grid prev/next wrap Consistent with our other keys like change track and via sizes. Fixes: https://gitlab.com/kicad/code/kicad/-/issues/9051 --- common/tool/common_tools.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/common/tool/common_tools.cpp b/common/tool/common_tools.cpp index 0f99017e86..3eabff709b 100644 --- a/common/tool/common_tools.cpp +++ b/common/tool/common_tools.cpp @@ -424,8 +424,10 @@ int COMMON_TOOLS::GridNext( const TOOL_EVENT& aEvent ) { int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; - if( currentGrid + 1 < int( m_grids.size() ) ) - currentGrid++; + currentGrid++; + + if( currentGrid >= int( m_grids.size() ) ) + currentGrid = 0; return OnGridChanged(); } @@ -435,8 +437,10 @@ int COMMON_TOOLS::GridPrev( const TOOL_EVENT& aEvent ) { int& currentGrid = m_toolMgr->GetSettings()->m_Window.grid.last_size_idx; - if( currentGrid > 0 ) - currentGrid--; + currentGrid--; + + if( currentGrid < 0 ) + currentGrid = (int) m_grids.size() - 1; return OnGridChanged(); }