From 6ba980b146b3260fc6fdf210e7f6de108c40ad4e Mon Sep 17 00:00:00 2001 From: Bishoy-at-pieces Date: Wed, 18 Sep 2024 20:28:32 +0300 Subject: [PATCH] fix ask issue where ask does not have context pipeline #172 --- ask/commands.py | 16 +++++++++------- settings.py | 33 +++++++++++++++++---------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/ask/commands.py b/ask/commands.py index 92114d6..ec58e5c 100644 --- a/ask/commands.py +++ b/ask/commands.py @@ -72,18 +72,18 @@ def run_async(self): def on_done(self,description): - self.description = description - if not self.description: - self.description = "No description provided" + self._description = description + if not description: + description = "No description provided" sublime.set_timeout_async(self.on_done_async,0) def on_done_async(self): if self.task == "fix": - pipeline = QGPTTaskPipeline(code_fix=QGPTTaskPipelineForCodeFix(error=self.description)) + task = QGPTTaskPipeline(code_fix=QGPTTaskPipelineForCodeFix(error=self._description)) elif self.task == "modify": - pipeline = QGPTTaskPipeline(code_modification=QGPTTaskPipelineForCodeModification(instruction=self.description)) - elif self.task == "comment": - pipeline = QGPTTaskPipeline(code_commentation=QGPTTaskPipelineForCodeCommentation()) + task = QGPTTaskPipeline(code_modification=QGPTTaskPipelineForCodeModification(instruction=self._description)) + else: # comment + task = QGPTTaskPipeline(code_commentation=QGPTTaskPipelineForCodeCommentation()) self.view.set_status('Pieces Refactoring', 'Copilot is thinking...') @@ -105,6 +105,7 @@ def on_done_async(self): ) ] ) + pipeline = QGPTPromptPipeline(task=task) try: res = PiecesSettings.api_client.copilot.question(" ",relevant,pipeline) except: @@ -153,6 +154,7 @@ def run(self, edit, code, selection): use_spaces = settings.get('translate_tabs_to_spaces') tab_size = settings.get('tab_size', 4) + # Get the current indentation level of the selected region current_line_region = self.view.line(region.begin()) current_line_text = self.view.substr(current_line_region) diff --git a/settings.py b/settings.py index 5086423..a02a6b9 100644 --- a/settings.py +++ b/settings.py @@ -1,7 +1,7 @@ from ._pieces_lib.pieces_os_client import SeededConnectorConnection,SeededTrackedApplication from ._pieces_lib.pieces_os_client.wrapper.websockets.base_websocket import BaseWebsocket from ._pieces_lib.pieces_os_client.wrapper import PiecesClient -from ._pieces_lib import notify +from ._pieces_lib import notify as notification from multiprocessing.pool import ThreadPool import sublime import os @@ -114,23 +114,24 @@ def pool(cls): def notify(title,message,level="info"): try: if level == "error": - notify.error(title, message, False) + notification.error(title, message, False) elif level == "warning": - notify.warning(title, message, False) + notification.warning(title, message, False) else: - notify.info(title, message, False) - notify.destroy() + notification.info(title, message, False) + notification.destroy() except: pass -if PiecesSettings.api_client.local_os == "MACOS": - os_icon = "pieces_server.icns" -elif PiecesSettings.api_client.local_os == "WINDOWS": - os_icon = "pieces_server.ico" -else: - os_icon = "pieces_server.png" - -package_path = os.path.join(sublime.packages_path(),"Pieces") if debug else os.path.join(sublime.installed_packages_path(),"Pieces.sublime-package") -path = os.path.join(package_path,"icons", os_icon) if os_icon else None -os_icon = path -notify.setup_notifications("Pieces for Sublime Text",os_icon,sender=None) + + if api_client.local_os == "MACOS": + os_icon = "pieces_server.icns" + elif api_client.local_os == "WINDOWS": + os_icon = "pieces_server.ico" + else: + os_icon = "pieces_server.png" + + package_path = os.path.join(sublime.packages_path(),"Pieces") if debug else os.path.join(sublime.installed_packages_path(),"Pieces.sublime-package") + path = os.path.join(package_path,"icons", os_icon) if os_icon else None + os_icon = path + notification.setup_notifications("Pieces for Sublime Text",os_icon,sender=None)