fix strange behavior on Backspace press in ST
authorAndrey Skvortsov <andrej.skvortzov@gmail.com>
Fri, 23 Dec 2016 18:40:31 +0300
changeset 1613 41ca586da9dc
parent 1612 bd03e1217fa5
child 1614 f8f05f849831
fix strange behavior on Backspace press in ST

Before:
if text was selected and cursor was at indention, one indention (two
spaces) was removed.

if cursor was at start position of the line, then nothing happened.

if cursor was in the middle of indention then on backspace more
indention were added


Now:
if text is selected, it will be removed.
if cursor is at start position, then new line will be removed.
if cursor was in the middle of indention one indention is removed.
editors/TextViewer.py
--- a/editors/TextViewer.py	Thu Dec 22 17:39:58 2016 +0300
+++ b/editors/TextViewer.py	Fri Dec 23 18:40:31 2016 +0300
@@ -894,11 +894,12 @@
                     key_handled = True
             elif key == wx.WXK_BACK:
                 if self.TextSyntax in ["ST", "ALL"]:
-                    indent = self.Editor.GetLineIndentation(line)
-                    if lineText.strip() == "" and indent > 0:
-                        self.Editor.DelLineLeft()
-                        self.Editor.AddText(" " * ((max(0, indent - 1) / 2) * 2))
-                        key_handled = True
+                    if not self.Editor.GetSelectedText():
+                        indent = self.Editor.GetColumn(self.Editor.GetCurrentPos())
+                        if lineText.strip() == "" and len(lineText) > 0 and indent > 0:
+                            self.Editor.DelLineLeft()
+                            self.Editor.AddText(" " * ((max(0, indent - 1) / 2) * 2))
+                            key_handled = True
             if not key_handled:
                 event.Skip()
         else: