| 65 | }; |
| 66 | |
| 67 | export class SettingsPanel { |
| 68 | private telemetry: { [key: string]: number } = {}; |
| 69 | private disposable?: vscode.Disposable; |
| 70 | |
| 71 | // Events |
| 72 | private settingsPanelActivated = new vscode.EventEmitter<void>(); |
| 73 | private configValuesChanged = new vscode.EventEmitter<void>(); |
| 74 | private configSelectionChanged = new vscode.EventEmitter<void>(); |
| 75 | private addConfigRequested = new vscode.EventEmitter<string>(); |
| 76 | |
| 77 | // Configuration data |
| 78 | private configValues: config.Configuration = { name: "" }; |
| 79 | private isIntelliSenseModeDefined: boolean = false; |
| 80 | private configIndexSelected: number = 0; |
| 81 | private compilerPaths: string[] = []; |
| 82 | |
| 83 | // WebviewPanel objects |
| 84 | private panel?: vscode.WebviewPanel; |
| 85 | private disposablesPanel?: vscode.Disposable; |
| 86 | private static readonly viewType: string = 'settingsPanel'; |
| 87 | private static readonly title: string = localize("c.cpp.configurations", 'C/C++ Configurations'); |
| 88 | |
| 89 | // Used to workaround a VS Code 1.56 regression in which webViewPanel.onDidChangeViewState |
| 90 | // gets called before the SettingsApp constructor is finished running. |
| 91 | // It repros with a higher probability in cases that cause a slower load, |
| 92 | // such as after switching to a Chinese language pack or in the remote scenario. |
| 93 | public initialized: boolean = false; |
| 94 | |
| 95 | constructor() { |
| 96 | this.disposable = vscode.Disposable.from( |
| 97 | this.settingsPanelActivated, |
| 98 | this.configValuesChanged, |
| 99 | this.configSelectionChanged, |
| 100 | this.addConfigRequested |
| 101 | ); |
| 102 | } |
| 103 | |
| 104 | public createOrShow(configSelection: string[], activeConfiguration: config.Configuration, errors: config.ConfigurationErrors, viewColumn?: vscode.ViewColumn): void { |
| 105 | const column: vscode.ViewColumn | undefined = viewColumn ?? vscode.window.activeTextEditor?.viewColumn; |
| 106 | |
| 107 | // Show existing panel |
| 108 | if (this.panel) { |
| 109 | this.panel.reveal(column, false); |
| 110 | return; |
| 111 | } |
| 112 | |
| 113 | this.initialized = false; |
| 114 | |
| 115 | // Create new panel |
| 116 | this.panel = vscode.window.createWebviewPanel( |
| 117 | SettingsPanel.viewType, |
| 118 | SettingsPanel.title, |
| 119 | column || vscode.ViewColumn.One, |
| 120 | { |
| 121 | enableCommandUris: true, |
| 122 | enableScripts: true, |
| 123 | retainContextWhenHidden: true, |
| 124 |
nothing calls this directly
no outgoing calls
no test coverage detected