Fixed bug in CodeFileEditor allowing to remove NEWLINE character between section header and section code
authorLaurent Bessard
Fri, 10 May 2013 11:49:22 +0200
changeset 1115 a4e58715ae41
parent 1114 1a97222ffee9
child 1116 300f98a8d4c6
Fixed bug in CodeFileEditor allowing to remove NEWLINE character between section header and section code
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():