Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit5f888ee

Browse files
authored
Fix issue with cpptools restarting when it should not (microsoft#8850)
1 parentc02440c commit5f888ee

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -746,6 +746,7 @@ export interface Client {
746746
onInterval():void;
747747
dispose():void;
748748
addFileAssociations(fileAssociations:string,languageId:string):void;
749+
sendAllSettings():void;
749750
sendDidChangeSettings(settings:any):void;
750751
}
751752

@@ -1481,15 +1482,15 @@ export class DefaultClient implements Client {
14811482
languageClientCrashedNeedsRestart=true;
14821483
telemetry.logLanguageServerEvent("languageClientCrash");
14831484
if(languageClientCrashTimes.length<5){
1484-
allClients.recreateClients(true);
1485+
allClients.recreateClients();
14851486
}else{
14861487
constelapsed:number=languageClientCrashTimes[languageClientCrashTimes.length-1]-languageClientCrashTimes[0];
14871488
if(elapsed<=3*60*1000){
14881489
vscode.window.showErrorMessage(localize('server.crashed2',"The language server crashed 5 times in the last 3 minutes. It will not be restarted."));
1489-
allClients.recreateClients(false);
1490+
allClients.recreateClients(true);
14901491
}else{
14911492
languageClientCrashTimes.shift();
1492-
allClients.recreateClients(true);
1493+
allClients.recreateClients();
14931494
}
14941495
}
14951496
returnCloseAction.DoNotRestart;
@@ -3319,5 +3320,6 @@ class NullClient implements Client {
33193320
this.stringEvent.dispose();
33203321
}
33213322
addFileAssociations(fileAssociations:string,languageId:string):void{}
3323+
sendAllSettings():void{}
33223324
sendDidChangeSettings(settings:any):void{}
33233325
}

‎Extension/src/LanguageServer/clientCollection.ts‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export class ClientCollection {
2525
privateactiveDocument?:vscode.TextDocument;
2626
publictimeTelemetryCollector:TimeTelemetryCollector=newTimeTelemetryCollector();
2727

28+
// This is a one-time switch to a mode that suppresses launching of the cpptools client process.
29+
privateuseFailsafeMode:boolean=false;
30+
2831
publicgetActiveClient():cpptools.Client{returnthis.activeClient;}
2932
publicgetNames():ClientKey[]{
3033
constresult:ClientKey[]=[];
@@ -104,22 +107,21 @@ export class ClientCollection {
104107
/**
105108
* creates a new client to replace one that crashed.
106109
*/
107-
publicasyncrecreateClients(transferFileOwnership:boolean):Promise<void>{
110+
publicasyncrecreateClients(switchToFailsafeMode?:boolean):Promise<void>{
108111

109112
// Swap out the map, so we are not changing it while iterating over it.
110113
constoldLanguageClients:Map<string,cpptools.Client>=this.languageClients;
111114
this.languageClients=newMap<string,cpptools.Client>();
112115

116+
if(switchToFailsafeMode){
117+
this.useFailsafeMode=true;
118+
}
119+
113120
for(constpairofoldLanguageClients){
114121
constclient:cpptools.Client=pair[1];
115122

116-
letnewClient:cpptools.Client;
117-
if(transferFileOwnership){
118-
newClient=this.createClient(client.RootFolder,true);
119-
client.TrackedDocuments.forEach(document=>this.transferOwnership(document,client));
120-
}else{
121-
newClient=cpptools.createNullClient();
122-
}
123+
constnewClient:cpptools.Client=this.createClient(client.RootFolder,true);
124+
client.TrackedDocuments.forEach(document=>this.transferOwnership(document,client));
123125

124126
if(this.activeClient===client){
125127
// It cannot be undefined. If there is an active document, we activate it later.
@@ -272,15 +274,14 @@ export class ClientCollection {
272274
}
273275

274276
publiccreateClient(folder?:vscode.WorkspaceFolder,deactivated?:boolean):cpptools.Client{
275-
constnewClient:cpptools.Client=cpptools.createClient(this,folder);
277+
constnewClient:cpptools.Client=this.useFailsafeMode ?cpptools.createNullClient() :cpptools.createClient(this,folder);
276278
if(deactivated){
277279
newClient.deactivate();// e.g. prevent the current config from switching.
278280
}
279281
constkey:string=folder ?util.asFolder(folder.uri) :defaultClientKey;
280282
this.languageClients.set(key,newClient);
281283
getCustomConfigProviders().forEach(provider=>newClient.onRegisterCustomConfigurationProvider(provider));
282-
constdefaultClient:cpptools.DefaultClient=<cpptools.DefaultClient>newClient;
283-
defaultClient.sendAllSettings();
284+
newClient.sendAllSettings();
284285
returnnewClient;
285286
}
286287

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp