QScintilla/MiniEditor.py

branch
conda
changeset 6718
24a7a749e132
parent 6645
ad476851d7e0
child 6721
48c3ca1ac264
--- a/QScintilla/MiniEditor.py	Sun Feb 10 15:58:15 2019 +0100
+++ b/QScintilla/MiniEditor.py	Sun Feb 10 16:53:42 2019 +0100
@@ -3090,18 +3090,17 @@
         elif line0.startswith("\\documentclass"):
             bindName = "dummy.tex"
         
-        # check filetype
-        if self.filetype in ["Python", "Python2", "Python3"]:
-            bindName = "dummy.py"
-        elif self.filetype == "Ruby":
-            bindName = "dummy.rb"
-        elif self.filetype == "D":
-            bindName = "dummy.d"
-        elif self.filetype == "Properties":
-            bindName = "dummy.ini"
+        if not bindName and self.filetype:
+            # check filetype
+            from . import Lexers
+            supportedLanguages = Lexers.getSupportedLanguages()
+            if self.filetype in supportedLanguages:
+                bindName = supportedLanguages[self.filetype][1]
+            elif self.filetype in ["Python", "Python2", "Python3"]:
+                bindName = "dummy.py"
         
-        # #! marker detection
-        if line0.startswith("#!"):
+        if not bindName and line0.startswith("#!"):
+            # #! marker detection
             if "python3" in line0:
                 bindName = "dummy.py"
                 self.filetype = "Python3"
@@ -3124,26 +3123,30 @@
                 bindName = "dummy.d"
                 self.filetype = "D"
         
-        # mode line detection: -*- mode: python -*-
-        match = re.search(r"mode[:=]\s*([-\w_.]+)", line0)
-        if match:
-            mode = match.group(1).lower()
-            if mode in ["python3", "pypy3"]:
-                bindName = "dummy.py"
-                self.filetype = "Python3"
-            elif mode in ["python2", "pypy2", "python", "pypy"]:
-                bindName = "dummy.py"
-                self.filetype = "Python2"
-            elif mode == "ruby":
-                bindName = "dummy.rb"
-                self.filetype = "Ruby"
-            elif mode == "perl":
-                bindName = "dummy.pl"
-            elif mode == "lua":
-                bindName = "dummy.lua"
-            elif mode in ["dmd", "d"]:
-                bindName = "dummy.d"
-                self.filetype = "D"
+        if not bindName:
+            # mode line detection: -*- mode: python -*-
+            match = re.search(r"mode[:=]\s*([-\w_.]+)", line0)
+            if match:
+                mode = match.group(1).lower()
+                if mode in ["python3", "pypy3"]:
+                    bindName = "dummy.py"
+                    self.filetype = "Python3"
+                elif mode in ["python2", "pypy2", "python", "pypy"]:
+                    bindName = "dummy.py"
+                    self.filetype = "Python2"
+                elif mode == "ruby":
+                    bindName = "dummy.rb"
+                    self.filetype = "Ruby"
+                elif mode == "perl":
+                    bindName = "dummy.pl"
+                elif mode == "lua":
+                    bindName = "dummy.lua"
+                elif mode in ["dmd", "d"]:
+                    bindName = "dummy.d"
+                    self.filetype = "D"
+        
+        if not bindName:
+            bindName = self.fileName
         
         return bindName
     

eric ide

mercurial