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

Commit 0695332

Browse files
authored
add ignore board (#554)
1 parent 93e760a commit 0695332

File tree

3 files changed

+31
-2
lines changed

3 files changed

+31
-2
lines changed

package.json

+4
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,10 @@
440440
"arduino.disableTestingOpen": {
441441
"type": "boolean",
442442
"default": false
443+
},
444+
"arduino.ignoreBoards": {
445+
"type": "array",
446+
"default": []
443447
}
444448
}
445449
},

src/arduino/vscodeSettings.ts

+10
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const configKeys = {
1111
AUTO_UPDATE_INDEX_FILES: "arduino.autoUpdateIndexFiles",
1212
ENABLE_USB_DETECTOIN: "arduino.enableUSBDetection",
1313
DISABLE_TESTING_OPEN: "arduino.disableTestingOpen",
14+
IGNORE_BOARDS: "arduino.ignoreBoards",
1415
};
1516

1617
export interface IVscodeSettings {
@@ -20,6 +21,7 @@ export interface IVscodeSettings {
2021
logLevel: string;
2122
enableUSBDetection: boolean;
2223
disableTestingOpen: boolean;
24+
ignoreBoards: string[];
2325
updateAdditionalUrls(urls: string | string[]): void;
2426
}
2527

@@ -59,6 +61,14 @@ export class VscodeSettings implements IVscodeSettings {
5961
return this.getConfigValue<boolean>(configKeys.DISABLE_TESTING_OPEN);
6062
}
6163

64+
public get ignoreBoards(): string[] {
65+
return this.getConfigValue<string[]>(configKeys.IGNORE_BOARDS);
66+
}
67+
68+
public set ignoreBoards(value: string[]) {
69+
this.setConfigValue(configKeys.IGNORE_BOARDS, value, true);
70+
}
71+
6272
public async updateAdditionalUrls(value) {
6373
await this.setConfigValue(configKeys.ADDITIONAL_URLS, value, true);
6474
}

src/serialmonitor/usbDetector.ts

+17-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,12 @@ export class UsbDetector {
7777
let bd = ArduinoContext.boardManager.installedBoards.get(boardKey);
7878
if (!bd) {
7979
ArduinoContext.boardManager.updatePackageIndex(deviceDescriptor.indexFile).then((shouldLoadPackageContent) => {
80-
vscode.window.showInformationMessage(`Install board package for ${deviceDescriptor.name}`, "Yes", "No").then((ans) => {
80+
const ignoreBoards = VscodeSettings.getInstance().ignoreBoards || [];
81+
if (ignoreBoards.indexOf(deviceDescriptor.name) >= 0) {
82+
return;
83+
}
84+
vscode.window.showInformationMessage(`Install board package for ${
85+
deviceDescriptor.name}`, "Yes", "No", "Don't ask again").then((ans) => {
8186
if (ans === "Yes") {
8287
ArduinoContext.arduinoApp.installBoard(deviceDescriptor.package, deviceDescriptor.architecture)
8388
.then(() => {
@@ -88,6 +93,9 @@ export class UsbDetector {
8893
bd = ArduinoContext.boardManager.installedBoards.get(boardKey);
8994
this.switchBoard(bd, deviceDescriptor);
9095
});
96+
} else if (ans === "Don't ask again") {
97+
ignoreBoards.push(deviceDescriptor.name);
98+
VscodeSettings.getInstance().ignoreBoards = ignoreBoards;
9199
}
92100
});
93101
});
@@ -96,11 +104,18 @@ export class UsbDetector {
96104
if (currBoard.board !== deviceDescriptor.id
97105
|| currBoard.platform.architecture !== deviceDescriptor.architecture
98106
|| currBoard.getPackageName() !== deviceDescriptor.package) {
107+
const ignoreBoards = VscodeSettings.getInstance().ignoreBoards || [];
108+
if (ignoreBoards.indexOf(deviceDescriptor.name) >= 0) {
109+
return;
110+
}
99111
vscode.window.showInformationMessage(`Detected board ${deviceDescriptor.name}. Would you like to switch to this board type?`,
100-
"Yes", "No")
112+
"Yes", "No", "Don't ask again")
101113
.then((ans) => {
102114
if (ans === "Yes") {
103115
return this.switchBoard(bd, deviceDescriptor);
116+
} else if (ans === "Don't ask again") {
117+
ignoreBoards.push(deviceDescriptor.name);
118+
VscodeSettings.getInstance().ignoreBoards = ignoreBoards;
104119
}
105120
});
106121
} else {

0 commit comments

Comments
 (0)