From 60b40579cbf85fdee647eb26d4010df91d53dd51 Mon Sep 17 00:00:00 2001
From: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
Date: Sun, 2 Feb 2025 18:43:11 +0100
Subject: [PATCH] router: reenable diff pair placement in shove mode

Fixes https://gitlab.com/kicad/code/kicad/issues/19547
---
 pcbnew/router/pns_diff_pair_placer.cpp | 20 +++++++++++++++++---
 1 file changed, 17 insertions(+), 3 deletions(-)

diff --git a/pcbnew/router/pns_diff_pair_placer.cpp b/pcbnew/router/pns_diff_pair_placer.cpp
index 1b68ecf5b2..4ba811cf8f 100644
--- a/pcbnew/router/pns_diff_pair_placer.cpp
+++ b/pcbnew/router/pns_diff_pair_placer.cpp
@@ -27,6 +27,7 @@
 #include "pns_topology.h"
 #include "pns_debug_decorator.h"
 #include "pns_arc.h"
+#include "pns_utils.h"
 
 namespace PNS {
 
@@ -366,10 +367,11 @@ bool DIFF_PAIR_PLACER::rhShoveOnly( const VECTOR2I& aP )
     LINE nLine( m_currentTrace.NLine() );
     ITEM_SET head;
 
-    head.Add( &pLine );
-    head.Add( &nLine );
+    m_shove->ClearHeads();
+    m_shove->AddHeads( pLine );
+    m_shove->AddHeads( nLine );
 
-    SHOVE::SHOVE_STATUS status = SHOVE::SH_INCOMPLETE; //->ShoveMultiLines( head );
+    SHOVE::SHOVE_STATUS status = m_shove->Run();
 
     m_currentNode = m_shove->CurrentNode();
 
@@ -377,12 +379,24 @@ bool DIFF_PAIR_PLACER::rhShoveOnly( const VECTOR2I& aP )
     {
         m_currentNode = m_shove->CurrentNode();
 
+        if( m_shove->HeadsModified( 0 ))
+            pLine = m_shove->GetModifiedHead(0);
+
+        if( m_shove->HeadsModified( 1 ))
+            nLine = m_shove->GetModifiedHead(1);
+
         if( !m_currentNode->CheckColliding( &m_currentTrace.PLine() ) &&
             !m_currentNode->CheckColliding( &m_currentTrace.NLine() ) )
         {
             m_fitOk = true;
         }
     }
+    else
+    {
+        // bring back previous state
+        m_currentTrace.SetShape( pLine.CLine(), nLine.CLine() );
+    }
+    
 
     return m_fitOk;
 }