@@ -26,7 +26,10 @@ public protocol CopilotSuggestionServiceType {
2626 ) async throws -> [ CopilotCompletion ]
2727 func notifyAccepted( _ completion: CopilotCompletion ) async
2828 func notifyRejected( _ completions: [ CopilotCompletion ] ) async
29- func openTextDocument( fileURL: URL , content: String ) async throws
29+ func notifyOpenTextDocument( fileURL: URL , content: String ) async throws
30+ func notifyChangeTextDocument( fileURL: URL , content: String ) async throws
31+ func notifyCloseTextDocument( fileURL: URL ) async throws
32+ func notifySaveTextDocument( fileURL: URL ) async throws
3033}
3134
3235protocol CopilotLSP {
@@ -252,13 +255,13 @@ public final class CopilotSuggestionService: CopilotBaseService, CopilotSuggesti
252255 )
253256 }
254257
255- public func openTextDocument (
258+ public func notifyOpenTextDocument (
256259 fileURL: URL ,
257260 content: String
258261 ) async throws {
259262 let languageId = languageIdentifierFromFileURL ( fileURL)
260263 let uri = " file:// \( fileURL. path) "
261- Logger . service. debug ( uri)
264+ Logger . service. debug ( " Open \( uri) " )
262265 try await server. sendNotification (
263266 . didOpenTextDocument(
264267 DidOpenTextDocumentParams (
@@ -272,6 +275,36 @@ public final class CopilotSuggestionService: CopilotBaseService, CopilotSuggesti
272275 )
273276 )
274277 }
278+
279+ public func notifyChangeTextDocument( fileURL: URL , content: String ) async throws {
280+ let languageId = languageIdentifierFromFileURL ( fileURL)
281+ let uri = " file:// \( fileURL. path) "
282+ Logger . service. debug ( " Change \( uri) " )
283+ try await server. sendNotification (
284+ . didOpenTextDocument(
285+ DidOpenTextDocumentParams (
286+ textDocument: . init(
287+ uri: uri,
288+ languageId: languageId. rawValue,
289+ version: 0 ,
290+ text: content
291+ )
292+ )
293+ )
294+ )
295+ }
296+
297+ public func notifySaveTextDocument( fileURL: URL ) async throws {
298+ let uri = " file:// \( fileURL. path) "
299+ Logger . service. debug ( " Save \( uri) " )
300+ try await server. sendNotification ( . didSaveTextDocument( . init( uri: uri) ) )
301+ }
302+
303+ public func notifyCloseTextDocument( fileURL: URL ) async throws {
304+ let uri = " file:// \( fileURL. path) "
305+ Logger . service. debug ( " Close \( uri) " )
306+ try await server. sendNotification ( . didCloseTextDocument( . init( uri: uri) ) )
307+ }
275308}
276309
277310extension InitializingServer : CopilotLSP {
0 commit comments