src/eric7/QScintilla/Shell.py

branch
eric7
changeset 10157
0020603d754b
parent 10069
435cc5875135
child 10161
b0ccdb47acde
--- a/src/eric7/QScintilla/Shell.py	Mon Aug 14 15:59:32 2023 +0200
+++ b/src/eric7/QScintilla/Shell.py	Thu Aug 17 14:47:52 2023 +0200
@@ -2412,27 +2412,29 @@
                 EricFileDialog.DontConfirmOverwrite,
             )
 
-            if fn:
-                if fn.endswith("."):
-                    fn = fn[:-1]
+            if not fn:
+                return
+
+            if fn.endswith("."):
+                fn = fn[:-1]
 
-                fpath = pathlib.Path(fn)
-                if not fpath.suffix:
-                    ex = selectedFilter.split("(*")[1].split(")")[0]
-                    if ex:
-                        fpath = fpath.with_suffix(ex)
-                if fpath.exists():
-                    res = EricMessageBox.yesNo(
-                        self,
-                        self.tr("Save Shell Contents"),
-                        self.tr(
-                            "<p>The file <b>{0}</b> already exists."
-                            " Overwrite it?</p>"
-                        ).format(fpath),
-                        icon=EricMessageBox.Warning,
-                    )
-                    if not res:
-                        return
+            fpath = pathlib.Path(fn)
+            if not fpath.suffix:
+                ex = selectedFilter.split("(*")[1].split(")")[0]
+                if ex:
+                    fpath = fpath.with_suffix(ex)
+            if fpath.exists():
+                res = EricMessageBox.yesNo(
+                    self,
+                    self.tr("Save Shell Contents"),
+                    self.tr(
+                        "<p>The file <b>{0}</b> already exists."
+                        " Overwrite it?</p>"
+                    ).format(fpath),
+                    icon=EricMessageBox.Warning,
+                )
+                if not res:
+                    return
             try:
                 with fpath.open("w", encoding="utf-8") as f:
                     f.write(txt)

eric ide

mercurial