eric7/QScintilla/Editor.py

branch
unittest
changeset 9070
eab09a1ab8ce
parent 8881
54e42bc2437a
child 9072
8d3ae97ee666
diff -r 938039ea15ca -r eab09a1ab8ce eric7/QScintilla/Editor.py
--- a/eric7/QScintilla/Editor.py	Tue May 17 14:21:13 2022 +0200
+++ b/eric7/QScintilla/Editor.py	Tue May 17 17:23:07 2022 +0200
@@ -522,6 +522,9 @@
         self.autosaveEnabled = Preferences.getEditor("AutosaveInterval") > 0
         self.autosaveManuallyDisabled = False
         
+        # code coverage related attributes
+        self.__coverageFile = ""
+        
         self.__initContextMenu()
         self.__initContextMenuMargins()
         
@@ -5662,6 +5665,8 @@
                 self.isPyFile()
             )
         
+        coEnable |= bool(self.__coverageFile)
+        
         # now check for syntax errors
         if self.hasSyntaxErrors():
             coEnable = False
@@ -6052,6 +6057,10 @@
         """
         files = []
         
+        if bool(self.__coverageFile):
+            # return the path of a previously used coverage file
+            return self.__coverageFile
+        
         # first check if the file belongs to a project and there is
         # a project coverage file
         if (
@@ -6107,6 +6116,7 @@
         Private method to handle the code coverage context menu action.
         """
         fn = self.__getCodeCoverageFile()
+        self.__coverageFile = fn
         if fn:
             from DataViews.PyCoverageDialog import PyCoverageDialog
             self.codecoverage = PyCoverageDialog()
@@ -6120,16 +6130,27 @@
         if self.showingNotcoveredMarkers:
             self.codeCoverageShowAnnotations(silent=True)
         
-    def codeCoverageShowAnnotations(self, silent=False):
+    def codeCoverageShowAnnotations(self, silent=False, coverageFile=None):
         """
         Public method to handle the show code coverage annotations context
         menu action.
         
-        @param silent flag indicating to not show any dialog (boolean)
+        @param silent flag indicating to not show any dialog (defaults to
+            False)
+        @type bool (optional)
+        @param coverageFile path of the file containing the code coverage data
+            (defaults to None)
+        @type str (optional)
         """
         self.__codeCoverageHideAnnotations()
         
-        fn = self.__getCodeCoverageFile()
+        fn = (
+            coverageFile
+            if bool(coverageFile) else
+            self.__getCodeCoverageFile()
+        )
+        self.__coverageFile = fn
+        
         if fn:
             from coverage import Coverage
             cover = Coverage(data_file=fn)

eric ide

mercurial