Skip to content

Commit

Permalink
fix context issue
Browse files Browse the repository at this point in the history
  • Loading branch information
bishoy-at-pieces committed Sep 9, 2024
1 parent ded1597 commit 14ebf21
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions copilot/ask_about_command.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,27 @@

class PiecesAskStreamAboutCommand(sublime_plugin.TextCommand):
def run(self,edit,type,pieces_query):
self.context = PiecesSettings.api_client.copilot.context
copilot.render_conversation(None) # Create conversation if not already
self.before_query = ""
if type == "file":
path = self.view.file_name()
if not path: return
self.context.paths.append(path)
PiecesSettings.api_client.copilot.context.paths.append(path)

elif type == "folder":
window = self.view.window()
if not window: return
paths = window.folders()
if not paths: return
[self.context.paths.append(path) for path in paths]
[PiecesSettings.api_client.copilot.context.paths.append(path) for path in paths]

elif type == "section":
# Get the all the selected text
data = "\n".join([self.view.substr(selection) for selection in self.view.sel()])
if not data:
return sublime.error_message("Please select a text")
self.context.raw_assets.append(data)
PiecesSettings.api_client.copilot.context.raw_assets.append(data)

copilot.render_conversation(None) # Create conversation if not already
if self.before_query:
pieces_query = self.before_query + pieces_query
copilot.add_query(pieces_query) # Add the query
Expand Down
4 changes: 2 additions & 2 deletions copilot/context_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,10 @@ def list_items(self):
for idx,path in enumerate(value):
res.append((path,f"paths_{idx}"))
elif key == "assets":
for idx,asset in enumerate(value.iterable):
for idx,asset in enumerate(value):
res.append((asset.name,f"assets_{idx}"))
elif key == "seeds":
for idx in range(len(value.iterable)):
for idx in range(len(value)):
res.append((f"Snippet {idx+1}",f"seeds_{idx}"))
return res

Expand Down

0 comments on commit 14ebf21

Please sign in to comment.