Fixed bug when deleting line between code and headers on Windows
authorLaurent Bessard
Tue, 14 May 2013 22:25:33 +0200
changeset 1139 f9cf74053b7d
parent 1138 cf2a6a7c87e8
child 1140 80a91fc91595
Fixed bug when deleting line between code and headers on Windows
editors/CodeFileEditor.py
--- a/editors/CodeFileEditor.py	Tue May 14 20:16:07 2013 +0200
+++ b/editors/CodeFileEditor.py	Tue May 14 22:25:33 2013 +0200
@@ -291,6 +291,13 @@
         selected = self.GetSelection()
         text_selected = selected[0] != selected[1]
         
+        # Test if caret is before Windows like new line
+        text = self.GetText()
+        if ord(text[current_pos]) == 13:
+            newline_size = 2
+        else:
+            newline_size = 1
+        
         # Disable to type any character in section header lines
         if (self.GetLineState(self.LineFromPosition(current_pos)) and
             not text_selected and
@@ -304,7 +311,7 @@
               (key == wx.WXK_BACK and
                self.GetLineState(self.LineFromPosition(max(0, current_pos - 1))) or
                key in [wx.WXK_DELETE, wx.WXK_NUMPAD_DELETE] and
-               self.GetLineState(self.LineFromPosition(min(len(self.GetText()), current_pos + 1))))):
+               self.GetLineState(self.LineFromPosition(min(len(text), current_pos + newline_size))))):
             return
         
         elif key == 32 and event.ControlDown():