# HG changeset patch # User Laurent Bessard # Date 1368184007 -7200 # Node ID 1aef6a7db08d9b7c7a7210b2889f942f19b6ec5d # Parent 300f98a8d4c66a296216d7d07eba113d65f57c13 Fixed CodeFileEditor allowing to have no line of code between two section headers diff -r 300f98a8d4c6 -r 1aef6a7db08d editors/CodeFileEditor.py --- 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():