eric7/JediInterface/JediServer.py

branch
eric7-maintenance
changeset 9111
4ac66b6c33a4
parent 8943
23f9c7b9e18e
child 9192
a763d57e23bc
diff -r 2b9bd8f97576 -r 4ac66b6c33a4 eric7/JediInterface/JediServer.py
--- a/eric7/JediInterface/JediServer.py	Mon May 02 15:53:05 2022 +0200
+++ b/eric7/JediInterface/JediServer.py	Wed Jun 01 13:48:49 2022 +0200
@@ -506,10 +506,11 @@
                 None,
                 self.tr("Rename Variable"),
                 self.tr("Enter the new name for the variable:"),
-                QLineEdit.EchoMode.Normal
+                QLineEdit.EchoMode.Normal,
+                editor.selectedText()
             )
             
-            if ok and newName:
+            if ok and newName and self.__vm.checkAllDirty():
                 filename = editor.getFileName()
                 line, index = editor.getCursorPosition()
                 source = editor.text()
@@ -546,7 +547,7 @@
                 QLineEdit.EchoMode.Normal
             )
             
-            if ok and newName:
+            if ok and newName and editor.checkDirty():
                 filename = editor.getFileName()
                 sLine, sIndex, eLine, eIndex = editor.getSelection()
                 source = editor.text()
@@ -580,22 +581,23 @@
             if not idString:
                 return
             
-            filename = editor.getFileName()
-            line, index = editor.getCursorPosition()
-            source = editor.text()
-            
-            self.__ensureActive(idString)
-            
-            euuid = str(uuid.uuid4())
-            self.__editors[euuid] = editor
-            
-            self.sendJson("inlineVariable", {
-                "FileName": filename,
-                "Source": source,
-                "Line": line + 1,
-                "Index": index,
-                "Uuid": euuid,
-            }, idString=idString)
+            if editor.checkDirty():
+                filename = editor.getFileName()
+                line, index = editor.getCursorPosition()
+                source = editor.text()
+                
+                self.__ensureActive(idString)
+                
+                euuid = str(uuid.uuid4())
+                self.__editors[euuid] = editor
+                
+                self.sendJson("inlineVariable", {
+                    "FileName": filename,
+                    "Source": source,
+                    "Line": line + 1,
+                    "Index": index,
+                    "Uuid": euuid,
+                }, idString=idString)
     
     @pyqtSlot()
     def refactoringExtractFunction(self):
@@ -615,7 +617,7 @@
                 QLineEdit.EchoMode.Normal
             )
             
-            if ok and newName:
+            if ok and newName and editor.checkDirty():
                 filename = editor.getFileName()
                 sLine, sIndex, eLine, eIndex = editor.getSelection()
                 source = editor.text()
@@ -852,25 +854,11 @@
         if "PATH" in clientEnv:
             clientEnv["PATH"] = self.__ui.getOriginalPathString()
         
-        if (projectLanguage.startswith("Python") or
-                projectLanguage == "MicroPython"):
-            # new code using virtual environments
-            venvManager = ericApp().getObject("VirtualEnvManager")
-            
-            # get virtual environment from project first
-            venvName = self.__ericProject.getDebugProperty("VIRTUALENV")
-            if not venvName:
-                # get it from debugger settings next
-                if projectLanguage in ("Python3", "MicroPython", "Cython"):
-                    venvName = Preferences.getDebugger("Python3VirtualEnv")
-                    if not venvName:
-                        venvName, _ = venvManager.getDefaultEnvironment()
-                else:
-                    venvName = ""
-            if venvName:
-                interpreter = venvManager.getVirtualenvInterpreter(
-                    venvName)
-                execPath = venvManager.getVirtualenvExecPath(venvName)
+        if projectLanguage in ("Python3", "MicroPython", "Cython"):
+            interpreter = self.__ericProject.getProjectInterpreter(
+                resolveGlobal=False)
+            if interpreter:
+                execPath = self.__ericProject.getProjectExecPath()
                 
                 # build a suitable environment
                 if execPath:

eric ide

mercurial