Skip to content

Commit

Permalink
Avoid redundant document loading
Browse files Browse the repository at this point in the history
  • Loading branch information
koliyo committed Oct 1, 2023
1 parent 8966d58 commit 36be64a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions Sources/hylo-lsp/DocumentProvider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,10 @@ actor DocumentProvider {
return resolveDocumentUrl(uri).absoluteString
}

public func preloadDocument(_ textDocument: TextDocumentProtocol) -> DocumentBuildRequest {
let uri = DocumentProvider.resolveDocumentUri(textDocument.uri)
return preloadDocument(uri)
}
// public func preloadDocument(_ textDocument: TextDocumentProtocol) -> DocumentBuildRequest {
// let uri = DocumentProvider.resolveDocumentUri(textDocument.uri)
// return preloadDocument(uri)
// }

private func preloadDocument(_ uri: DocumentUri) -> DocumentBuildRequest {
let document = requestDocument(uri)
Expand Down
5 changes: 3 additions & 2 deletions Sources/hylo-lsp/HyloServer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ public struct HyloNotificationHandler : NotificationHandler {


public func textDocumentDidOpen(_ params: TextDocumentDidOpenParams) async {
_ = await state.documentProvider.preloadDocument(params.textDocument)
// _ = await state.documentProvider.preloadDocument(params.textDocument)
}

public func textDocumentDidChange(_ params: TextDocumentDidChangeParams) async {
_ = await state.documentProvider.preloadDocument(params.textDocument)
// _ = await state.documentProvider.preloadDocument(params.textDocument)
// TODO: Handle changes from input (not stored on disk)
}

public func textDocumentDidClose(_ params: TextDocumentDidCloseParams) async {
Expand Down

0 comments on commit 36be64a

Please sign in to comment.