Skip to content

Commit 7288b61

Browse files
committed
Add workspace.didUpdateFilespace
1 parent dea46ab commit 7288b61

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

Core/Sources/Service/RealtimeSuggestionController.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,10 @@ public actor RealtimeSuggestionController {
192192

193193
func notifyEditingFileChange(editor: AXUIElement) async {
194194
guard let fileURL = try? await Environment.fetchCurrentFileURL(),
195-
let (workspace, filespace) = try? await Service.shared.workspacePool
195+
let (workspace, _) = try? await Service.shared.workspacePool
196196
.fetchOrCreateWorkspaceAndFilespace(fileURL: fileURL)
197197
else { return }
198-
workspace.suggestionPlugin?.notifyUpdateFile(filespace: filespace, content: editor.value)
198+
await workspace.didUpdateFilespace(fileURL: fileURL, content: editor.value)
199199
}
200200
}
201201

Core/Sources/Service/WorkspaceExtension/SuggestionWorkspacePlugin.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@ final class SuggestionServiceWorkspacePlugin: WorkspacePlugin {
8585
override func didSaveFilespace(_ filespace: Filespace) {
8686
notifySaveFile(filespace: filespace)
8787
}
88+
89+
override func didUpdateFilespace(_ filespace: Filespace, content: String) {
90+
notifyUpdateFile(filespace: filespace, content: content)
91+
}
8892

8993
override func didCloseFilespace(_ fileURL: URL) {
9094
Task {

Tool/Sources/Workspace/Workspace.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ open class WorkspacePlugin {
3838

3939
open func didOpenFilespace(_: Filespace) {}
4040
open func didSaveFilespace(_: Filespace) {}
41+
open func didUpdateFilespace(_: Filespace, content: String) {}
4142
open func didCloseFilespace(_: URL) {}
4243
}
4344

@@ -133,5 +134,13 @@ public final class Workspace {
133134
public func closeFilespace(fileURL: URL) {
134135
filespaces[fileURL] = nil
135136
}
137+
138+
@WorkspaceActor
139+
public func didUpdateFilespace(fileURL: URL, content: String) {
140+
guard let filespace = filespaces[fileURL] else { return }
141+
for plugin in plugins.values {
142+
plugin.didUpdateFilespace(filespace, content: content)
143+
}
144+
}
136145
}
137146

0 commit comments

Comments
 (0)