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

Commit86a8139

Browse files
authored
Fix files.associations updating. (microsoft#5626)
Fix formicrosoft#5618Scenario 1: Manually change files.associations. Bug: We weren't sending files.associations along with the settings change.Scenario 2: Open a .C file. Bug: The language associations need to be changed before sending the didOpen.
1 parent34457f2 commit86a8139

File tree

4 files changed

+50
-22
lines changed

4 files changed

+50
-22
lines changed

‎Extension/src/LanguageServer/client.ts‎

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ export interface Client {
527527
onInterval():void;
528528
dispose():Thenable<void>;
529529
addFileAssociations(fileAssociations:string,is_c:boolean):void;
530+
sendDidChangeSettings(settings:any):void;
530531
}
531532

532533
exportfunctioncreateClient(allClients:ClientCollection,workspaceFolder?:vscode.WorkspaceFolder):Client{
@@ -1267,7 +1268,7 @@ export class DefaultClient implements Client {
12671268
returnnewLanguageClient(`cpptools`,serverOptions,clientOptions);
12681269
}
12691270

1270-
publicsendDidChangeSettings():void{
1271+
publicsendAllSettings():void{
12711272
letcppSettingsScoped:{[key:string]:any}={};
12721273
// Gather the C_Cpp settings
12731274
{
@@ -1293,21 +1294,26 @@ export class DefaultClient implements Client {
12931294
tabSize:vscode.workspace.getConfiguration("editor.tabSize",this.RootUri)
12941295
},
12951296
files:{
1296-
exclude:vscode.workspace.getConfiguration("files.exclude",this.RootUri)
1297+
exclude:vscode.workspace.getConfiguration("files.exclude",this.RootUri),
1298+
associations:newOtherSettings().filesAssociations
12971299
},
12981300
search:{
12991301
exclude:vscode.workspace.getConfiguration("search.exclude",this.RootUri)
13001302
}
13011303
};
13021304

1305+
this.sendDidChangeSettings(settings);
1306+
}
1307+
1308+
publicsendDidChangeSettings(settings:any):void{
13031309
// Send settings json to native side
13041310
this.notifyWhenReady(()=>{
13051311
this.languageClient.sendNotification(DidChangeSettingsNotification,{settings,workspaceFolderUri:this.RootPath});
13061312
});
13071313
}
13081314

13091315
publiconDidChangeSettings(event:vscode.ConfigurationChangeEvent,isFirstClient:boolean):{[key:string]:string}{
1310-
this.sendDidChangeSettings();
1316+
this.sendAllSettings();
13111317
letchangedSettings:{[key:string]:string};
13121318
changedSettings=this.settingsTracker.getChangedSettings();
13131319
this.notifyWhenReady(()=>{
@@ -1965,8 +1971,7 @@ export class DefaultClient implements Client {
19651971

19661972
// TODO: Handle new associations without a reload.
19671973
this.associations_for_did_change=newSet<string>(["c","i","cpp","cc","cxx","c++","cp","hpp","hh","hxx","h++","hp","h","ii","ino","inl","ipp","tcc","idl"]);
1968-
letsettings:OtherSettings=newOtherSettings(this.RootUri);
1969-
letassocs:any=settings.filesAssociations;
1974+
letassocs:any=newOtherSettings().filesAssociations;
19701975
for(letassocinassocs){
19711976
letdotIndex:number=assoc.lastIndexOf('.');
19721977
if(dotIndex!==-1){
@@ -2689,4 +2694,5 @@ class NullClient implements Client {
26892694
returnPromise.resolve();
26902695
}
26912696
addFileAssociations(fileAssociations:string,is_c:boolean):void{}
2697+
sendDidChangeSettings(settings:any):void{}
26922698
}

‎Extension/src/LanguageServer/clientCollection.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export class ClientCollection {
169169
this.languageClients.set(path,newClient);
170170
newClient.deactivate();// e.g. prevent the current config from switching.
171171
letdefaultClient:cpptools.DefaultClient=<cpptools.DefaultClient>newClient;
172-
defaultClient.sendDidChangeSettings();
172+
defaultClient.sendAllSettings();
173173
}
174174
});
175175
}
@@ -196,7 +196,7 @@ export class ClientCollection {
196196
this.languageClients.set(key,newClient);
197197
getCustomConfigProviders().forEach(provider=>newClient.onRegisterCustomConfigurationProvider(provider));
198198
letdefaultClient:cpptools.DefaultClient=<cpptools.DefaultClient>newClient;
199-
defaultClient.sendDidChangeSettings();
199+
defaultClient.sendAllSettings();
200200
returnnewClient;
201201
}
202202
}

‎Extension/src/LanguageServer/extension.ts‎

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { TreeNode, NodeType } from './referencesModel';
1414
import{UI,getUI}from'./ui';
1515
import{Client}from'./client';
1616
import{ClientCollection}from'./clientCollection';
17-
import{CppSettings}from'./settings';
17+
import{CppSettings,OtherSettings}from'./settings';
1818
import{PersistentWorkspaceState,PersistentState}from'./persistentState';
1919
import{getLanguageConfig}from'./languageConfig';
2020
import{getCustomConfigProviders}from'./customProviders';
@@ -564,20 +564,31 @@ export function processDelayedDidOpen(document: vscode.TextDocument): void {
564564
if(!client.TrackedDocuments.has(document)){
565565
// If not yet tracked, process as a newly opened file. (didOpen is sent to server in client.takeOwnership()).
566566
client.TrackedDocuments.add(document);
567+
letfinishDidOpen=(doc:vscode.TextDocument)=>{
568+
client.provideCustomConfiguration(doc.uri,undefined);
569+
client.notifyWhenReady(()=>{
570+
client.takeOwnership(doc);
571+
client.onDidOpenTextDocument(doc);
572+
});
573+
};
574+
letlanguageChanged:boolean=false;
567575
// Work around vscode treating ".C" or ".H" as c, by adding this file name to file associations as cpp
568576
if((document.uri.path.endsWith(".C")||document.uri.path.endsWith(".H"))&&document.languageId==="c"){
569577
letcppSettings:CppSettings=newCppSettings();
570578
if(cppSettings.autoAddFileAssociations){
571579
constfileName:string=path.basename(document.uri.fsPath);
572580
constmappingString:string=fileName+"@"+document.uri.fsPath;
573581
client.addFileAssociations(mappingString,false);
582+
client.sendDidChangeSettings({files:{associations:newOtherSettings().filesAssociations}});
583+
vscode.languages.setTextDocumentLanguage(document,"cpp").then((newDoc:vscode.TextDocument)=>{
584+
finishDidOpen(newDoc);
585+
});
586+
languageChanged=true;
574587
}
575588
}
576-
client.provideCustomConfiguration(document.uri,undefined);
577-
client.notifyWhenReady(()=>{
578-
client.takeOwnership(document);
579-
client.onDidOpenTextDocument(document);
580-
});
589+
if(!languageChanged){
590+
finishDidOpen(document);
591+
}
581592
}
582593
}
583594
}

‎Extension/src/LanguageServer/protocolFilter.ts‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import { Middleware } from 'vscode-languageclient';
99
import{ClientCollection}from'./clientCollection';
1010
import{Client}from'./client';
1111
import*asvscodefrom'vscode';
12-
import{CppSettings}from'./settings';
12+
import{CppSettings,OtherSettings}from'./settings';
1313
import{onDidChangeActiveTextEditor,processDelayedDidOpen}from'./extension';
1414

1515
exportfunctioncreateProtocolFilter(clients:ClientCollection):Middleware{
@@ -32,22 +32,33 @@ export function createProtocolFilter(clients: ClientCollection): Middleware {
3232
letme:Client=clients.getClientFor(document.uri);
3333
if(clients.checkOwnership(me,document)){
3434
me.TrackedDocuments.add(document);
35+
letfinishDidOpen=(doc:vscode.TextDocument)=>{
36+
me.provideCustomConfiguration(doc.uri,undefined);
37+
me.notifyWhenReady(()=>{
38+
sendMessage(doc);
39+
me.onDidOpenTextDocument(doc);
40+
if(editor&&editor===vscode.window.activeTextEditor){
41+
onDidChangeActiveTextEditor(editor);
42+
}
43+
});
44+
};
45+
letlanguageChanged:boolean=false;
3546
if((document.uri.path.endsWith(".C")||document.uri.path.endsWith(".H"))&&document.languageId==="c"){
3647
letcppSettings:CppSettings=newCppSettings();
3748
if(cppSettings.autoAddFileAssociations){
3849
constfileName:string=path.basename(document.uri.fsPath);
3950
constmappingString:string=fileName+"@"+document.uri.fsPath;
4051
me.addFileAssociations(mappingString,false);
52+
me.sendDidChangeSettings({files:{associations:newOtherSettings().filesAssociations}});
53+
vscode.languages.setTextDocumentLanguage(document,"cpp").then((newDoc:vscode.TextDocument)=>{
54+
finishDidOpen(newDoc);
55+
});
56+
languageChanged=true;
4157
}
4258
}
43-
me.provideCustomConfiguration(document.uri,undefined);
44-
me.notifyWhenReady(()=>{
45-
sendMessage(document);
46-
me.onDidOpenTextDocument(document);
47-
if(editor&&editor===vscode.window.activeTextEditor){
48-
onDidChangeActiveTextEditor(editor);
49-
}
50-
});
59+
if(!languageChanged){
60+
finishDidOpen(document);
61+
}
5162
}
5263
}else{
5364
// NO-OP

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp