From 7cb3e729eee70d708396e0f17f657c49ac45757f Mon Sep 17 00:00:00 2001
From: YuSanka <yusanka@gmail.com>
Date: Mon, 8 Mar 2021 14:19:58 +0100
Subject: [PATCH] Fixed #6182 - First line custom gcode not aligned left in the
 tool tip

---
 src/slic3r/GUI/DoubleSlider.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/src/slic3r/GUI/DoubleSlider.cpp b/src/slic3r/GUI/DoubleSlider.cpp
index c12d36112..81945061b 100644
--- a/src/slic3r/GUI/DoubleSlider.cpp
+++ b/src/slic3r/GUI/DoubleSlider.cpp
@@ -1317,7 +1317,12 @@ wxString Control::get_tooltip(int tick/*=-1*/)
                         "This code won't be processed during G-code generation.");
         
         // Show custom Gcode as a first string of tooltop
-        tooltip = "    ";
+        std::string space = "   ";
+        tooltip = space;
+        auto format_gcode = [space](std::string gcode) {
+            boost::replace_all(gcode, "\n", "\n" + space);
+            return gcode;
+        };
         tooltip +=  
         	tick_code_it->type == ColorChange ?
         		(m_mode == SingleExtruder ?
@@ -1329,7 +1334,7 @@ wxString Control::get_tooltip(int tick/*=-1*/)
 	                format_wxstr(_L("Custom template (\"%1%\")"), gcode(Template)) :
 		            tick_code_it->type == ToolChange ?
 		                format_wxstr(_L("Extruder (tool) is changed to Extruder \"%1%\""), tick_code_it->extruder) :                
-		                from_u8(tick_code_it->extra);// tick_code_it->type == Custom
+		                from_u8(format_gcode(tick_code_it->extra));// tick_code_it->type == Custom
 
         // If tick is marked as a conflict (exclamation icon),
         // we should to explain why