Skip to content

Commit e36406a

Browse files
committed
Support close file notification based on filespace expiry
1 parent 138856f commit e36406a

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

Core/Sources/Service/ScheduledCleaner.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ public final class ScheduledCleaner {
55
// occasionally cleanup workspaces.
66
Task { @ServiceActor in
77
while !Task.isCancelled {
8-
try await Task.sleep(nanoseconds: 8 * 60 * 60 * 1_000_000_000)
8+
try await Task.sleep(nanoseconds: 2 * 60 * 60 * 1_000_000_000)
99
for (url, workspace) in workspaces {
1010
if workspace.isExpired {
1111
workspaces[url] = nil

Core/Sources/Service/SuggestionCommandHandler/WindowBaseCommandHandler.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -199,15 +199,11 @@ struct WindowBaseCommandHandler: SuggestionCommandHandler {
199199

200200
presenter.discardSuggestion(fileURL: fileURL)
201201

202-
let result = UpdatedContent(
202+
return .init(
203203
content: String(lines.joined(separator: "")),
204204
newSelection: .cursor(cursorPosition),
205205
modifications: extraInfo.modifications
206206
)
207-
208-
workspace.notifyUpdateFile(filespace: filespace, content: result.content)
209-
210-
return result
211207
}
212208

213209
return nil

Core/Sources/Service/Workspace.swift

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ final class Filespace {
1818
let fileURL: URL
1919
private(set) lazy var language: String = languageIdentifierFromFileURL(fileURL).rawValue
2020
var suggestions: [CopilotCompletion] = [] {
21-
didSet { lastSuggestionUpdateTime = Environment.now() }
21+
didSet { refreshUpdateTime() }
2222
}
2323

2424
// stored for pseudo command handler
@@ -51,6 +51,10 @@ final class Filespace {
5151
suggestionSourceSnapshot = .init(linesHash: -1, cursorPosition: .outOfScope)
5252
}
5353
}
54+
55+
func refreshUpdateTime() {
56+
lastSuggestionUpdateTime = Environment.now()
57+
}
5458
}
5559

5660
@ServiceActor
@@ -179,6 +183,8 @@ final class Workspace {
179183
workspaces[workspaceURL] = workspace
180184
if existedFilespace == nil {
181185
workspace.notifyOpenFile(filespace: filespace)
186+
} else {
187+
filespace.refreshUpdateTime()
182188
}
183189
return (workspace, filespace)
184190
}

0 commit comments

Comments
 (0)