Skip to content

Commit 06132d4

Browse files
committed
Remove prefixing spaces when send content to plugins
1 parent 42d9d7e commit 06132d4

1 file changed

Lines changed: 11 additions & 2 deletions

File tree

Core/Sources/ChatService/ChatService.swift

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,16 @@ public final class ChatService: ObservableObject {
5656
await runningPlugin.send(content: content)
5757
} else if let pluginType = plugins[command] {
5858
let plugin = pluginType.init(inside: chatGPTService, delegate: self)
59-
await plugin.send(content: String(content.dropFirst(command.count + 1)))
59+
if #available(macOS 13.0, *) {
60+
await plugin.send(
61+
content: String(
62+
content.dropFirst(command.count + 1)
63+
.trimmingPrefix(while: { $0 == " " })
64+
)
65+
)
66+
} else {
67+
await plugin.send(content: String(content.dropFirst(command.count + 1)))
68+
}
6069
} else {
6170
_ = try await chatGPTService.send(content: content, summary: nil)
6271
}
@@ -106,7 +115,7 @@ extension ChatService: ChatPluginDelegate {
106115
public func pluginDidEnd(_: ChatPlugin) {
107116
runningPlugin = nil
108117
}
109-
118+
110119
public func shouldStartAnotherPlugin(_ type: ChatPlugin.Type, withContent content: String) {
111120
let plugin = type.init(inside: chatGPTService, delegate: self)
112121
Task {

0 commit comments

Comments
 (0)