From 2ce5e5c1d7ac87e6ca6cec32dc1242a1b2423007 Mon Sep 17 00:00:00 2001
From: Haseeb <haseeb_heaven@yahoo.com>
Date: Sun, 7 Jan 2024 06:57:51 +0530
Subject: [PATCH] Fix code editor opening logic

---
 libs/interpreter_lib.py | 21 +++++++++++----------
 1 file changed, 11 insertions(+), 10 deletions(-)

diff --git a/libs/interpreter_lib.py b/libs/interpreter_lib.py
index eae11f2..0ac5f2b 100644
--- a/libs/interpreter_lib.py
+++ b/libs/interpreter_lib.py
@@ -373,6 +373,7 @@ def interpreter_main(self):
         self.logger.info(f"Code Interpreter - v{self.interpreter_version}")
         os_platform = self.utility_manager.get_os_platform()
         os_name = os_platform[0]
+        extracted_code = None
 
         # Seting the mode.
         if self.SCRIPT_MODE:
@@ -446,16 +447,16 @@ def interpreter_main(self):
                         self.logger.info(f"Opening code in **vim** editor {code_file}")
                         subprocess.call(['vim', code_file])
                         continue
-                    
-                    # Open the code in default editor.
-                    if os_platform[0].lower() == 'macos':
-                        self.logger.info(f"Opening code in default editor {code_file}")
-                        subprocess.call(('open', code_file))
-                    elif os_platform[0].lower() == 'linux':
-                        subprocess.call(('xdg-open', code_file))
-                    elif os_platform[0].lower() == 'windows':
-                        os.startfile(code_file)
-                    continue
+                    else:
+                        # Open the code in default editor.
+                        if os_platform[0].lower() == 'macos':
+                            self.logger.info(f"Opening code in default editor {code_file}")
+                            subprocess.call(('open', code_file))
+                        elif os_platform[0].lower() == 'linux':
+                            subprocess.call(('xdg-open', code_file))
+                        elif os_platform[0].lower() == 'windows':
+                            os.startfile(code_file)
+                        continue
                                     
                 # MODE - Command section.
                 elif any(command in task.lower() for command in ['/mode ', '/md ']):