5
5
import { StaticFeature , FeatureState } from 'vscode-languageclient/lib/common/api'
6
6
import { DidSaveTextDocumentNotification , DocumentSelector , Emitter , ServerCapabilities , TextDocumentSyncOptions } from 'vscode-languageserver-protocol'
7
7
import * as vscode from 'vscode'
8
- import { updateFile , willShutdownNotificationType , WillShutdownParams } from './customRequests'
8
+ import { willShutdownNotificationType , WillShutdownParams } from './customRequests'
9
9
import { Infrastructure } from './infrastructure'
10
- import { LanguageClient , LanguageClientManager } from './languageClient'
10
+ import { LanguageClientManager } from './languageClient'
11
11
import { getServices } from './services'
12
12
13
13
interface ResolvedTextDocumentSyncCapabilities {
@@ -17,7 +17,7 @@ interface ResolvedTextDocumentSyncCapabilities {
17
17
// Initialize the file content into the lsp server for implementations that don't support open/close notifications
18
18
export class InitializeTextDocumentFeature implements StaticFeature {
19
19
private didOpenTextDocumentDisposable : Disposable | undefined
20
- constructor ( private languageClient : LanguageClient ) { }
20
+ constructor ( private languageClient : LanguageClientManager , private infrastructure : Infrastructure ) { }
21
21
22
22
fillClientCapabilities ( ) : void { }
23
23
@@ -27,10 +27,11 @@ export class InitializeTextDocumentFeature implements StaticFeature {
27
27
return
28
28
}
29
29
30
+ const infrastructure = this . infrastructure
30
31
const languageClient = this . languageClient
31
32
async function saveFile ( textDocument : vscode . TextDocument ) {
32
33
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 )
34
35
35
36
// Always send notification even if the server doesn't support it (because csharp register the didSave feature too late)
36
37
await languageClient . sendNotification ( DidSaveTextDocumentNotification . type , {
0 commit comments