Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Commit 6b1a1d6

Browse files
committed
Add analyzeOnSettingChange
1 parent 625610f commit 6b1a1d6

File tree

5 files changed

+32
-13
lines changed

5 files changed

+32
-13
lines changed

README.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ This extension provides several commands in the Command Palette (<kbd>F1</kbd> o
8282
| `arduino.defaultBaudRate` | Default baud rate for the serial port monitor. The default value is 115200. Supported values are 300, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 74880, 115200, 230400 and 250000 |
8383
| `arduino.defaultTimestampFormat` | Format of timestamp printed before each line of Serial Monitor output. You can find list of all available placeholders [here](https://github.com/samsonjs/strftime#supported-specifiers). |
8484
| `arduino.disableIntelliSenseAutoGen` | When `true` vscode-arduino will not auto-generate an IntelliSense configuration (i.e. `.vscode/c_cpp_properties.json`) by analyzing Arduino's compiler output. |
85-
| `arduino.analyzeOnOpen` | When true, automatically run analysis when the project is opened. |
85+
| `arduino.analyzeOnOpen` | When true, automatically run analysis when the project is opened. Only works when `arduino.analyzeOnSettingChange` is true. |
86+
| `arduino.analyzeOnSettingChange` | When true, automatically run analysis when board, configuration, or sketch settings are changed. |
8687

8788
The following Visual Studio Code settings are available for the Arduino extension. These can be set in global user preferences <kbd>Ctrl</kbd> + <kbd>,</kbd> *or* <kbd>Cmd</kbd> + <kbd>,</kbd> or workspace settings (`.vscode/settings.json`). The latter overrides the former.
8889

package.json

+7-2
Original file line numberDiff line numberDiff line change
@@ -544,8 +544,13 @@
544544
},
545545
"arduino.analyzeOnOpen": {
546546
"type": "boolean",
547-
"default": false,
548-
"markdownDescription": "When true, automatically run analysis when the project is opened."
547+
"default": true,
548+
"markdownDescription": "When true, automatically run analysis when the project is opened. Only works when `arduino.analyzeOnSettingChange` is true."
549+
},
550+
"arduino.analyzeOnSettingChange": {
551+
"type": "boolean",
552+
"default": true,
553+
"markdownDescription": "When true, automatically run analysis when board, configuration, or sketch settings are changed."
549554
}
550555
}
551556
},

src/arduino/arduino.ts

+12-10
Original file line numberDiff line numberDiff line change
@@ -101,16 +101,18 @@ export class ArduinoApp {
101101
}
102102
}
103103

104-
// set up event handling for IntelliSense analysis
105-
const requestAnalysis = async () => {
106-
if (isCompilerParserEnabled()) {
107-
await this._analysisManager.requestAnalysis();
108-
}
109-
};
110-
const dc = DeviceContext.getInstance();
111-
dc.onChangeBoard(requestAnalysis);
112-
dc.onChangeConfiguration(requestAnalysis);
113-
dc.onChangeSketch(requestAnalysis);
104+
if (this._settings.analyzeOnSettingChange) {
105+
// set up event handling for IntelliSense analysis
106+
const requestAnalysis = async () => {
107+
if (isCompilerParserEnabled()) {
108+
await this._analysisManager.requestAnalysis();
109+
}
110+
};
111+
const dc = DeviceContext.getInstance();
112+
dc.onChangeBoard(requestAnalysis);
113+
dc.onChangeConfiguration(requestAnalysis);
114+
dc.onChangeSketch(requestAnalysis);
115+
}
114116
}
115117

116118
/**

src/arduino/arduinoSettings.ts

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export interface IArduinoSettings {
2323
preferences: Map<string, string>;
2424
useArduinoCli: boolean;
2525
defaultTimestampFormat: string;
26+
analyzeOnSettingChange: boolean;
2627
reloadPreferences(): void;
2728
}
2829

@@ -169,6 +170,10 @@ export class ArduinoSettings implements IArduinoSettings {
169170
return this._defaultTimestampFormat;
170171
}
171172

173+
public get analyzeOnSettingChange(): boolean {
174+
return VscodeSettings.getInstance().analyzeOnSettingChange;
175+
}
176+
172177
public reloadPreferences() {
173178
this._preferences = util.parseConfigFile(this.preferencePath);
174179
if (this.preferences.get("sketchbook.path")) {

src/arduino/vscodeSettings.ts

+6
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ const configKeys = {
2121
DISABLE_INTELLISENSE_AUTO_GEN: "arduino.disableIntelliSenseAutoGen",
2222
DEFAULT_TIMESTAMP_FORMAT: "arduino.defaultTimestampFormat",
2323
ANALYZE_ON_OPEN: "arduino.analyzeOnOpen",
24+
ANALYZE_ON_SETTING_CHANGE: "arduino.analyzeOnSettingChange",
2425
};
2526

2627
export interface IVscodeSettings {
@@ -39,6 +40,7 @@ export interface IVscodeSettings {
3940
disableIntelliSenseAutoGen: boolean;
4041
defaultTimestampFormat: string;
4142
analyzeOnOpen: boolean;
43+
analyzeOnSettingChange: boolean;
4244
updateAdditionalUrls(urls: string[]): void;
4345
}
4446

@@ -130,6 +132,10 @@ export class VscodeSettings implements IVscodeSettings {
130132
return this.getConfigValue<boolean>(configKeys.ANALYZE_ON_OPEN);
131133
}
132134

135+
public get analyzeOnSettingChange(): boolean {
136+
return this.getConfigValue<boolean>(configKeys.ANALYZE_ON_SETTING_CHANGE);
137+
}
138+
133139
public async updateAdditionalUrls(value) {
134140
await this.setConfigValue(configKeys.ADDITIONAL_URLS, value, true);
135141
}

0 commit comments

Comments
 (0)