Skip to content

Commit 922719b

Browse files
authored
Merge pull request #58 from CodinGame/update-infrastructure
Use infrastructure to save file
2 parents 4013848 + 7ea222c commit 922719b

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

src/extensions.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
import { StaticFeature, FeatureState } from 'vscode-languageclient/lib/common/api'
66
import { DidSaveTextDocumentNotification, DocumentSelector, Emitter, ServerCapabilities, TextDocumentSyncOptions } from 'vscode-languageserver-protocol'
77
import * as vscode from 'vscode'
8-
import { updateFile, willShutdownNotificationType, WillShutdownParams } from './customRequests'
8+
import { willShutdownNotificationType, WillShutdownParams } from './customRequests'
99
import { Infrastructure } from './infrastructure'
10-
import { LanguageClient, LanguageClientManager } from './languageClient'
10+
import { LanguageClientManager } from './languageClient'
1111
import { getServices } from './services'
1212

1313
interface ResolvedTextDocumentSyncCapabilities {
@@ -17,7 +17,7 @@ interface ResolvedTextDocumentSyncCapabilities {
1717
// Initialize the file content into the lsp server for implementations that don't support open/close notifications
1818
export class InitializeTextDocumentFeature implements StaticFeature {
1919
private didOpenTextDocumentDisposable: Disposable | undefined
20-
constructor (private languageClient: LanguageClient) {}
20+
constructor (private languageClient: LanguageClientManager, private infrastructure: Infrastructure) {}
2121

2222
fillClientCapabilities (): void {}
2323

@@ -27,10 +27,11 @@ export class InitializeTextDocumentFeature implements StaticFeature {
2727
return
2828
}
2929

30+
const infrastructure = this.infrastructure
3031
const languageClient = this.languageClient
3132
async function saveFile (textDocument: vscode.TextDocument) {
3233
if (documentSelector != null && vscode.languages.match(documentSelector, textDocument) > 0 && textDocument.uri.scheme === 'file') {
33-
await updateFile(textDocument.uri.toString(), textDocument.getText(), languageClient)
34+
await infrastructure.saveFileContent?.(textDocument, vscode.TextDocumentSaveReason.Manual, languageClient)
3435

3536
// Always send notification even if the server doesn't support it (because csharp register the didSave feature too late)
3637
await languageClient.sendNotification(DidSaveTextDocumentNotification.type, {

src/languageClient.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ export class LanguageClientManager implements LanguageClient {
299299
this.languageClient.registerFeature(new FileSystemFeature(this.infrastructure, this))
300300

301301
if (!this.infrastructure.automaticTextDocumentUpdate) {
302-
this.languageClient.registerFeature(new InitializeTextDocumentFeature(this))
302+
this.languageClient.registerFeature(new InitializeTextDocumentFeature(this, this.infrastructure))
303303
}
304304

305305
await this.languageClient.start()

0 commit comments

Comments
 (0)