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

Commitbc70ea8

Browse files
authored
Merge branch 'master' into seanmcm/0_23_0_changelog2
2 parents968d6c5 +bbfea25 commitbc70ea8

File tree

4 files changed

+148
-85
lines changed

4 files changed

+148
-85
lines changed

‎Extension/src/LanguageServer/configurations.ts‎

Lines changed: 101 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,18 @@ export class CppProperties {
204204
privateonSelectionChanged():void{
205205
this.selectionChanged.fire(this.CurrentConfigurationIndex);
206206
if(this.settingsPanel){
207-
this.settingsPanel.updateConfigUI(this.configurationJson.configurations[this.currentConfigurationIndex.Value]);
207+
this.ensurePropertiesFile().then(()=>{
208+
if(this.propertiesFile){
209+
// Clear out any modifications we may have made internally by parsing the json file
210+
if(this.parsePropertiesFile()){
211+
// Update the UI with new selected configuration
212+
this.settingsPanel.updateConfigUI(this.configurationJson.configurations[this.currentConfigurationIndex.Value]);
213+
}else{
214+
// Parse failed, open json file
215+
vscode.workspace.openTextDocument(this.propertiesFile);
216+
}
217+
}
218+
});
208219
}
209220
this.handleSquiggles();
210221
}
@@ -380,7 +391,7 @@ export class CppProperties {
380391
config.includePath=["${default}"];
381392
}
382393
config.includePath.splice(config.includePath.length,0,path);
383-
fs.writeFileSync(this.propertiesFile.fsPath,JSON.stringify(this.configurationJson,null,4));
394+
this.writeToJson();
384395
this.handleConfigurationChange();
385396
});
386397
}
@@ -396,7 +407,7 @@ export class CppProperties {
396407
}else{
397408
deleteconfig.configurationProvider;
398409
}
399-
fs.writeFileSync(this.propertiesFile.fsPath,JSON.stringify(this.configurationJson,null,4));
410+
this.writeToJson();
400411
this.handleConfigurationChange();
401412
resolve();
402413
});
@@ -418,7 +429,7 @@ export class CppProperties {
418429
this.parsePropertiesFileAndHandleSquiggles();// Clear out any modifications we may have made internally.
419430
letconfig:Configuration=this.CurrentConfiguration;
420431
config.compileCommands=path;
421-
fs.writeFileSync(this.propertiesFile.fsPath,JSON.stringify(this.configurationJson,null,4));
432+
this.writeToJson();
422433
this.handleConfigurationChange();
423434
});
424435
}
@@ -428,6 +439,18 @@ export class CppProperties {
428439
this.handleConfigurationEditCommand(vscode.window.showTextDocument);
429440
return;
430441
}
442+
443+
// Before changing the current configuration index, save any edits from the UI.
444+
if(this.settingsPanel){
445+
if(this.settingsPanel.isDirty()){
446+
this.parsePropertiesFile();// Clear out any modifications we may have made internally.
447+
// Get the changes from the UI and save to json file
448+
letconfig:Configuration=this.settingsPanel.getLastValuesFromConfigUI();
449+
this.configurationJson.configurations[this.currentConfigurationIndex.Value]=config;
450+
this.writeToJson();
451+
}
452+
}
453+
431454
this.currentConfigurationIndex.Value=index;
432455
this.onSelectionChanged();
433456
}
@@ -564,56 +587,6 @@ export class CppProperties {
564587
}
565588
}
566589

567-
privateasyncensurePropertiesFile():Promise<void>{
568-
if(this.propertiesFile&&fs.existsSync(this.propertiesFile.fsPath)){
569-
return;
570-
}else{
571-
try{
572-
if(!fs.existsSync(this.configFolder)){
573-
fs.mkdirSync(this.configFolder);
574-
}
575-
576-
letfullPathToFile:string=path.join(this.configFolder,"c_cpp_properties.json");
577-
letfilePath:vscode.Uri=vscode.Uri.file(fullPathToFile).with({scheme:"untitled"});
578-
579-
letdocument:vscode.TextDocument=awaitvscode.workspace.openTextDocument(filePath);
580-
581-
letedit:vscode.WorkspaceEdit=newvscode.WorkspaceEdit();
582-
if(this.configurationJson){
583-
this.resetToDefaultSettings(true);
584-
}
585-
this.applyDefaultIncludePathsAndFrameworks();
586-
letsettings:CppSettings=newCppSettings(this.rootUri);
587-
if(settings.defaultConfigurationProvider){
588-
this.configurationJson.configurations.forEach(config=>{
589-
config.configurationProvider=settings.defaultConfigurationProvider;
590-
});
591-
settings.update("default.configurationProvider",undefined);// delete the setting
592-
}
593-
letsavedKnownCompilers:KnownCompiler[]=this.configurationJson.configurations[0].knownCompilers;
594-
deletethis.configurationJson.configurations[0].knownCompilers;
595-
596-
edit.insert(document.uri,newvscode.Position(0,0),JSON.stringify(this.configurationJson,null,4));
597-
598-
this.configurationJson.configurations[0].knownCompilers=savedKnownCompilers;
599-
awaitvscode.workspace.applyEdit(edit);
600-
601-
// Fix for issue 163
602-
// https://github.com/Microsoft/vscppsamples/issues/163
603-
// Save the file to disk so that when the user tries to re-open the file it exists.
604-
// Before this fix the file existed but was unsaved, so we went through the same
605-
// code path and reapplied the edit.
606-
awaitdocument.save();
607-
608-
this.propertiesFile=vscode.Uri.file(path.join(this.configFolder,"c_cpp_properties.json"));
609-
610-
}catch(err){
611-
vscode.window.showErrorMessage(`Failed to create "${this.configFolder}":${err.message}`);
612-
}
613-
}
614-
return;
615-
}
616-
617590
publichandleConfigurationEditCommand(onSuccess:(document:vscode.TextDocument)=>void):void{
618591
letotherSettings:OtherSettings=newOtherSettings(this.rootUri);
619592
if(otherSettings.settingsEditor==="ui"){
@@ -655,15 +628,25 @@ export class CppProperties {
655628
}
656629

657630
privateonSettingsPanelViewStateChanged(e:ViewStateEvent):void{
658-
if(e.isActive&&this.configurationJson){
659-
// The settings UI became visible or active.
660-
// Ensure settingsPanel is referencing current configuration
661-
this.settingsPanel.updateConfigUI(this.configurationJson.configurations[this.currentConfigurationIndex.Value]);
662-
}else{
631+
if(!e.isDirty&&e.isActive&&this.configurationJson){
632+
this.ensurePropertiesFile().then(()=>{
633+
if(this.propertiesFile){
634+
if(this.parsePropertiesFile()){
635+
// The settings UI became visible or active.
636+
// Ensure settingsPanel has copy of latest current configuration
637+
this.settingsPanel.updateConfigUI(this.configurationJson.configurations[this.currentConfigurationIndex.Value]);
638+
}else{
639+
// Parse failed, open json file
640+
vscode.workspace.openTextDocument(this.propertiesFile);
641+
}
642+
}
643+
});
644+
}elseif(e.isDirty){
663645
console.assert(this.configurationJson);
664-
// The settings UI closed or is out of focus, save any changes to current configuration
665-
// No need to get the changed values from settingsPanel because settingsPanel has a reference of this.configurationJson
666-
fs.writeFileSync(this.propertiesFile.fsPath,JSON.stringify(this.configurationJson,null,4));
646+
this.parsePropertiesFile();// Clear out any modifications we may have made internally.
647+
letconfig:Configuration=this.settingsPanel.getLastValuesFromConfigUI();
648+
this.configurationJson.configurations[this.currentConfigurationIndex.Value]=config;
649+
this.writeToJson();
667650
}
668651
}
669652

@@ -693,6 +676,56 @@ export class CppProperties {
693676
this.updateServerOnFolderSettingsChange();
694677
}
695678

679+
privateasyncensurePropertiesFile():Promise<void>{
680+
if(this.propertiesFile&&fs.existsSync(this.propertiesFile.fsPath)){
681+
return;
682+
}else{
683+
try{
684+
if(!fs.existsSync(this.configFolder)){
685+
fs.mkdirSync(this.configFolder);
686+
}
687+
688+
letfullPathToFile:string=path.join(this.configFolder,"c_cpp_properties.json");
689+
letfilePath:vscode.Uri=vscode.Uri.file(fullPathToFile).with({scheme:"untitled"});
690+
691+
letdocument:vscode.TextDocument=awaitvscode.workspace.openTextDocument(filePath);
692+
693+
letedit:vscode.WorkspaceEdit=newvscode.WorkspaceEdit();
694+
if(this.configurationJson){
695+
this.resetToDefaultSettings(true);
696+
}
697+
this.applyDefaultIncludePathsAndFrameworks();
698+
letsettings:CppSettings=newCppSettings(this.rootUri);
699+
if(settings.defaultConfigurationProvider){
700+
this.configurationJson.configurations.forEach(config=>{
701+
config.configurationProvider=settings.defaultConfigurationProvider;
702+
});
703+
settings.update("default.configurationProvider",undefined);// delete the setting
704+
}
705+
letsavedKnownCompilers:KnownCompiler[]=this.configurationJson.configurations[0].knownCompilers;
706+
deletethis.configurationJson.configurations[0].knownCompilers;
707+
708+
edit.insert(document.uri,newvscode.Position(0,0),JSON.stringify(this.configurationJson,null,4));
709+
710+
this.configurationJson.configurations[0].knownCompilers=savedKnownCompilers;
711+
awaitvscode.workspace.applyEdit(edit);
712+
713+
// Fix for issue 163
714+
// https://github.com/Microsoft/vscppsamples/issues/163
715+
// Save the file to disk so that when the user tries to re-open the file it exists.
716+
// Before this fix the file existed but was unsaved, so we went through the same
717+
// code path and reapplied the edit.
718+
awaitdocument.save();
719+
720+
this.propertiesFile=vscode.Uri.file(path.join(this.configFolder,"c_cpp_properties.json"));
721+
722+
}catch(err){
723+
vscode.window.showErrorMessage(`Failed to create "${this.configFolder}":${err.message}`);
724+
}
725+
}
726+
return;
727+
}
728+
696729
privateparsePropertiesFileAndHandleSquiggles():void{
697730
if(this.parsePropertiesFile()){
698731
this.handleSquiggles();
@@ -773,7 +806,7 @@ export class CppProperties {
773806

774807
if(dirty){
775808
try{
776-
fs.writeFileSync(this.propertiesFile.fsPath,JSON.stringify(this.configurationJson,null,4));
809+
this.writeToJson();
777810
}catch(err){
778811
// Ignore write errors, the file may be under source control. Updated settings will only be modified in memory.
779812
vscode.window.showWarningMessage(`Attempt to update "${this.propertiesFile.fsPath}" failed (do you have write access?)`);
@@ -1073,6 +1106,11 @@ export class CppProperties {
10731106
}
10741107
}
10751108

1109+
privatewriteToJson():void{
1110+
console.assert(this.propertiesFile);
1111+
fs.writeFileSync(this.propertiesFile.fsPath,JSON.stringify(this.configurationJson,null,4));
1112+
}
1113+
10761114
publiccheckCppProperties():void{
10771115
// Check for change properties in case of file watcher failure.
10781116
letpropertiesFile:string=path.join(this.configFolder,"c_cpp_properties.json");

‎Extension/src/LanguageServer/settingsPanel.ts‎

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,12 @@ const elementId: { [key: string]: string } = {
2323

2424
exportinterfaceViewStateEvent{
2525
isActive:boolean;
26+
isDirty:boolean;
2627
}
2728

2829
exportclassSettingsPanel{
2930
privateconfigValues:config.Configuration;
31+
privateisIntelliSenseModeDefined:boolean=false;
3032
privateconfigDirty:boolean=false;
3133
privatesettingsPanelViewStateChanged=newvscode.EventEmitter<ViewStateEvent>();
3234
privatepanel:vscode.WebviewPanel;
@@ -89,6 +91,10 @@ export class SettingsPanel {
8991
returnthis.settingsPanelViewStateChanged.event;
9092
}
9193

94+
publicisDirty():boolean{
95+
returnthis.configDirty;
96+
}
97+
9298
publicgetLastValuesFromConfigUI():config.Configuration{
9399
returnthis.configValues;
94100
}
@@ -122,7 +128,7 @@ export class SettingsPanel {
122128
privateonPanelDisposed():void{
123129
// Notify listener config panel is not active
124130
if(this.configDirty){
125-
letviewState:ViewStateEvent={isActive:false};
131+
letviewState:ViewStateEvent={isActive:false,isDirty:this.configDirty};
126132
this.settingsPanelViewStateChanged.fire(viewState);
127133
}
128134

@@ -133,25 +139,28 @@ export class SettingsPanel {
133139
}
134140

135141
privateupdateWebview(configuration:config.Configuration):void{
136-
this.configValues=configuration;
137-
// Send a message to the webview to update the values from json.
142+
this.configValues=Object.assign({},configuration);// Copy configuration values
143+
this.isIntelliSenseModeDefined=(this.configValues.intelliSenseMode!==undefined);
138144
if(this.panel){
139-
this.panel.webview.postMessage({command:'update',config:configuration});
145+
// Send a message to the webview to update the values
146+
this.panel.webview.postMessage({command:'update',config:this.configValues});
140147
this.configDirty=false;
141148
}
142149
}
143150

144151
privateonViewStateChanged(e:vscode.WebviewPanelOnDidChangeViewStateEvent):void{
145-
letviewState:ViewStateEvent={isActive:e.webviewPanel.active};
152+
letviewState:ViewStateEvent={isActive:e.webviewPanel.active,isDirty:this.configDirty};
146153
if(this.configDirty||e.webviewPanel.active){
147154
this.settingsPanelViewStateChanged.fire(viewState);
155+
this.configDirty=false;
148156
}
149157
}
150158

151159
privateonWindowStateChanged(e:vscode.WindowState):void{
152-
letviewState:ViewStateEvent={isActive:e.focused};
153-
if(this.configDirty||e.focused){
160+
letviewState:ViewStateEvent={isActive:this.panel.active,isDirty:this.configDirty};
161+
if(this.configDirty||this.panel.active){
154162
this.settingsPanelViewStateChanged.fire(viewState);
163+
this.configDirty=false;
155164
}
156165
}
157166

@@ -185,7 +194,11 @@ export class SettingsPanel {
185194
this.configValues.defines=entries.filter(e=>e);
186195
break;
187196
caseelementId.intelliSenseMode:
188-
this.configValues.intelliSenseMode=message.value;
197+
if(message.value!=="${default}"||this.isIntelliSenseModeDefined){
198+
this.configValues.intelliSenseMode=message.value;
199+
}else{
200+
this.configValues.intelliSenseMode=undefined;
201+
}
189202
break;
190203
caseelementId.cStandard:
191204
this.configValues.cStandard=message.value;

‎Extension/ui/settings.html‎

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@
125125
}
126126

127127
textarea {
128+
white-space: nowrap;
128129
padding:4px;
129130
font-size:13px;
130131
font-family: Menlo, Monaco, Consolas,"Droid Sans Mono","Courier New", monospace,"Droid Sans Fallback";
@@ -322,7 +323,8 @@
322323
<divclass="main-title">IntelliSense Configurations</div>
323324
<divstyle="color: var(--vscode-foreground);">
324325
Use this editor to edit basic IntelliSense settings defined in the underlying<ahref="command:C_Cpp.ConfigurationEditJSON"title="Edit configurations in JSON file">c_cpp_properties.json</a> file.
325-
Only the setting values of the active configuration can be modified at a time. Switch active configurations to modify a different configurations on this editor. To edit multiple configurations or set additional settings go to<ahref="command:C_Cpp.ConfigurationEditJSON"title="Edit configurations in JSON file">c_cpp_properties.json</a>.
326+
Changes made in this editor only apply to the active configuration. To modify other configurations<ahref="command:C_Cpp.ConfigurationSelect"title="Change the active configuration">change the active configuration</a>.
327+
To edit multiple configurations at once, or additional settings not shown here, go to<ahref="command:C_Cpp.ConfigurationEditJSON"title="Edit configurations in JSON file">c_cpp_properties.json</a>.
326328
</div>
327329
</div>
328330

@@ -331,19 +333,20 @@
331333

332334
<!-- sections -->
333335
<divclass="section">
334-
<divclass="section-title">Configurationidentifier</div>
336+
<divclass="section-title">Configurationname</div>
335337
<divclass="section-text">
336-
The identifier of the active configuration.<code>Mac</code>,<code>Linux</code>, and<code>Win32</code> are special identifiers for configurations that will be auto-selected on those platforms, but the identifier can be anything.
338+
A friendly name that identifies a configuration.<code>Mac</code>,<code>Linux</code>, and<code>Win32</code> are special identifiers for configurations that will be auto-selected on those platforms, but the name of the identifier can be anything.
339+
To edit the name of the current active configuration, go to the<ahref="command:C_Cpp.ConfigurationEditJSON"title="Edit configurations in JSON file">c_cpp_properties.json</a> file and edit the<code>name</code> property.
337340
</div>
338341
<divclass="section-input"><inputclass="input-disabled"type="text"id=activeConfigstyle="width: 290px"disabled>
339-
<astyle="padding-left: 6px;"href="command:C_Cpp.ConfigurationSelect"title="Selectactive configuration">Select active configuration</a>
342+
<astyle="padding-left: 6px;"href="command:C_Cpp.ConfigurationSelect"title="Change theactive configuration">Change the active configuration</a>
340343
</div>
341344
</div>
342345

343346
<divclass="section">
344347
<divclass="section-title">Compiler path</div>
345348
<divclass="section-text">
346-
Full path of the compiler being used to build, e.g.<code>/usr/bin/gcc</code>, to enable more accurate IntelliSense.
349+
The full path of the compiler being used to build, e.g.<code>/usr/bin/gcc</code>, to enable more accurate IntelliSense.
347350
Args can be added to modify the includes/defines used, e.g.<code>-nostdinc++</code>,<code>-m32</code>, etc., but paths with spaces must be surrounded by double quotes<code>"</code> if args are used.
348351
</div>
349352
<divclass="section-input">
@@ -354,10 +357,13 @@
354357
<divclass="section">
355358
<divclass="section-title">IntelliSense mode</div>
356359
<divclass="section-text">
357-
If set, it overrides the default mode used by the IntelliSense engine. Windows defaults to msvc-x64, Linux defaults to gcc-x64, and Mac defaults to clang-x64.
360+
The IntelliSense mode used by the IntelliSense engine. The<code>${default}</code> mode will choose the default for that platform.
361+
Windows defaults to<code>msvc-x64</code>, Linux defaults to<code>gcc-x64</code>, and Mac defaults to<code>clang-x64</code>.
362+
Select a specific IntelliSense mode to override the<code>${default}</code> mode.
358363
</div>
359364
<divclass="section-input">
360365
<selectid="intelliSenseMode">
366+
<optionvalue="${default}">${default}</option>
361367
<optionvalue="msvc-x64">msvc-x64</option>
362368
<optionvalue="gcc-x64">gcc-x64</option>
363369
<optionvalue="clang-x64">clang-x64</option>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp