# HG changeset patch
# User Laurent Bessard
# Date 1368179362 -7200
# Node ID a4e58715ae4120771272a8b613f5145e39e9c500
# Parent  1a97222ffee92f80df9c463bec11bfc250a16b72
Fixed bug in CodeFileEditor allowing to remove NEWLINE character between section header and section code

diff -r 1a97222ffee9 -r a4e58715ae41 editors/CodeFileEditor.py
--- a/editors/CodeFileEditor.py	Fri May 10 11:48:04 2013 +0200
+++ b/editors/CodeFileEditor.py	Fri May 10 11:49:22 2013 +0200
@@ -273,9 +273,16 @@
         if self.CallTipActive():
             self.CallTipCancel()
         key = event.GetKeyCode()
-        
-        if (self.GetLineState(self.LineFromPosition(self.GetSelection()[0])) and
-            key not in NAVIGATION_KEYS):
+        caret = self.GetSelection()[0]
+        print (key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE], 
+               self.GetLineState(self.LineFromPosition(min(len(self.GetText()), caret + 1))))
+        
+        if (self.GetLineState(self.LineFromPosition(caret)) and
+            key not in NAVIGATION_KEYS or
+            key == wx.WXK_BACK and
+            self.GetLineState(self.LineFromPosition(max(0, caret - 1))) or
+            key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE] and
+            self.GetLineState(self.LineFromPosition(min(len(self.GetText()), caret + 1)))):
             return
         
         elif key == 32 and event.ControlDown():