Skip to content

Commit 13f1f50

Browse files
committed
Fix Chat with Selection with no code selected
1 parent 4f199b5 commit 13f1f50

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,8 @@ extension WindowBaseCommandHandler {
410410
return """
411411
\(language.isEmpty ? "" : "You must always reply in \(language)")
412412
You are a senior programmer, you will answer my questions concisely. If you are replying with code, embed the code in a code block in markdown.
413+
414+
You don't have any code in advance, ask me to provide it when needed.
413415
"""
414416
}
415417
return """
@@ -451,6 +453,14 @@ extension WindowBaseCommandHandler {
451453
summary: "\(customCommandPrefix) Chatting about selected code in `\(fileURL.lastPathComponent)` from `\(selection.start.line + 1):\(selection.start.character + 1)` to `\(selection.end.line + 1):\(selection.end.character)`.\nThe code will persist in the conversation."
452454
))
453455
}
456+
} else {
457+
await chat.chatGPTService.mutateHistory { history in
458+
history.append(.init(
459+
role: .assistant,
460+
content: "",
461+
summary: "\(customCommandPrefix) System prompt is updated."
462+
))
463+
}
454464
}
455465

456466
if let sendingMessageImmediately, !sendingMessageImmediately.isEmpty {

0 commit comments

Comments
 (0)