eric6/QScintilla/Editor.py

changeset 8222
5994b80b8760
parent 8221
0572a215bd2f
child 8228
772103b14c18
--- a/eric6/QScintilla/Editor.py	Sun Apr 11 16:53:48 2021 +0200
+++ b/eric6/QScintilla/Editor.py	Sun Apr 11 18:45:10 2021 +0200
@@ -2165,13 +2165,13 @@
         if self.filetype == "JavaScript":
             return True
         
-        if self.filetype == "":
-            if (
-                self.fileName and
-                os.path.splitext(self.fileName)[1] == ".js"
-            ):
-                self.filetype = "JavaScript"
-                return True
+        if (
+            self.filetype == "" and
+            self.fileName and
+            os.path.splitext(self.fileName)[1] == ".js"
+        ):
+            self.filetype = "JavaScript"
+            return True
         
         return False
     
@@ -2248,25 +2248,25 @@
         """
         if (
             mtype & (self.SC_MOD_INSERTTEXT | self.SC_MOD_DELETETEXT) and
-            linesAdded != 0
+            linesAdded != 0 and
+            self.breaks
         ):
-            if self.breaks:
-                bps = []    # list of breakpoints
-                for handle, (ln, cond, temp, enabled, ignorecount) in (
-                    self.breaks.items()
-                ):
-                    line = self.markerLine(handle) + 1
-                    if ln != line:
-                        bps.append((ln, line))
-                        self.breaks[handle] = (line, cond, temp, enabled,
-                                               ignorecount)
-                self.inLinesChanged = True
-                for ln, line in sorted(bps, reverse=linesAdded > 0):
-                    index1 = self.breakpointModel.getBreakPointIndex(
-                        self.fileName, ln)
-                    index2 = self.breakpointModel.index(index1.row(), 1)
-                    self.breakpointModel.setData(index2, line)
-                self.inLinesChanged = False
+            bps = []    # list of breakpoints
+            for handle, (ln, cond, temp, enabled, ignorecount) in (
+                self.breaks.items()
+            ):
+                line = self.markerLine(handle) + 1
+                if ln != line:
+                    bps.append((ln, line))
+                    self.breaks[handle] = (line, cond, temp, enabled,
+                                           ignorecount)
+            self.inLinesChanged = True
+            for ln, line in sorted(bps, reverse=linesAdded > 0):
+                index1 = self.breakpointModel.getBreakPointIndex(
+                    self.fileName, ln)
+                index2 = self.breakpointModel.index(index1.row(), 1)
+                self.breakpointModel.setData(index2, line)
+            self.inLinesChanged = False
         
     def __restoreBreakpoints(self):
         """
@@ -3362,13 +3362,13 @@
             return False
         
         res = self.writeFile(fn)
-        if res:
+        if (
+            res and
+            self.project.isOpen() and
+            self.project.startswithProjectPath(fn)
+        ):
             # save to project, if a project is loaded
-            if (
-                self.project.isOpen() and
-                self.project.startswithProjectPath(fn)
-            ):
-                self.project.appendFile(fn)
+            self.project.appendFile(fn)
         
         return res
         
@@ -7060,11 +7060,13 @@
         
         # See it is text to insert.
         if len(txt) and txt >= " ":
-            if self.hasSelectedText():
-                if txt in Editor.EncloseChars:
-                    encloseSelectedText(Editor.EncloseChars[txt])
-                    ev.accept()
-                    return
+            if (
+                self.hasSelectedText() and
+                txt in Editor.EncloseChars
+            ):
+                encloseSelectedText(Editor.EncloseChars[txt])
+                ev.accept()
+                return
             
             super().keyPressEvent(ev)
         else:

eric ide

mercurial