editors/CodeFileEditor.py
changeset 1117 1aef6a7db08d
parent 1115 a4e58715ae41
child 1124 b1705000eba1
--- a/editors/CodeFileEditor.py	Fri May 10 12:11:54 2013 +0200
+++ b/editors/CodeFileEditor.py	Fri May 10 13:06:47 2013 +0200
@@ -206,11 +206,14 @@
         for section in SECTIONS_NAMES:
             section_comments = self.SectionsComments[section]
             text += section_comments["comment"]
-            if not parts[section].startswith("\n") or parts[section] == "\n":
+            if parts[section] == "":
                 text += "\n"
-            text += parts[section]
-            if not parts[section].endswith("\n"):
-                text += "\n"
+            else:
+                if not parts[section].startswith("\n"):
+                    text += "\n"
+                text += parts[section]
+                if not parts[section].endswith("\n"):
+                    text += "\n"
         return text
 
     def RefreshView(self, scroll_to_highlight=False):
@@ -273,16 +276,12 @@
         if self.CallTipActive():
             self.CallTipCancel()
         key = event.GetKeyCode()
-        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)))):
+        current_pos = self.GetSelection()[0]
+        
+        if (self.GetLineState(self.LineFromPosition(current_pos)) and
+            key not in NAVIGATION_KEYS + [
+                wx.WXK_RETURN,
+                wx.WXK_NUMPAD_ENTER]):
             return
         
         elif key == 32 and event.ControlDown():