Skip to content

Commit 3714ccc

Browse files
shouldDetectPorts
1 parent 34a16a3 commit 3714ccc

File tree

2 files changed

+18
-4
lines changed

2 files changed

+18
-4
lines changed

src/VueWebviewPanel.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Disposable, Webview, WebviewPanel, window, Uri, ViewColumn, ExtensionCo
22
import { getUri } from "./utilities/getUri";
33
import { getNonce } from "./utilities/getNonce";
44
import { ARDUINO_ERRORS, ARDUINO_MESSAGES, ArduinoProjectStatus, WebviewToExtensionMessage } from './shared/messages';
5-
import { arduinoCLI, arduinoExtensionChannel, arduinoProject, changeTheme, loadArduinoConfiguration, openExample, updateStateCompileUpload } from "./extension";
5+
import { arduinoCLI, arduinoExtensionChannel, arduinoProject, changeTheme, loadArduinoConfiguration, openExample, shouldDetectPorts, updateStateCompileUpload } from "./extension";
66
import { ARDUINO_SKETCH_EXTENSION } from "./ArduinoProject";
77

88
const path = require('path');
@@ -14,7 +14,9 @@ export class VueWebviewPanel {
1414
private _disposables: Disposable[] = [];
1515
public static currentPanel: VueWebviewPanel | undefined;
1616
private usbChange() {
17-
VueWebviewPanel.sendMessage({ command: ARDUINO_MESSAGES.REQUEST_BOARD_CONNECTED, errorMessage: "", payload: "" });
17+
if(shouldDetectPorts()) {
18+
VueWebviewPanel.sendMessage({ command: ARDUINO_MESSAGES.REQUEST_BOARD_CONNECTED, errorMessage: "", payload: "" });
19+
}
1820
}
1921
private constructor(panel: WebviewPanel, extensionUri: Uri) {
2022
this._panel = panel;

src/extension.ts

+14-2
Original file line numberDiff line numberDiff line change
@@ -176,18 +176,30 @@ async function verifyUserDirectorySetting() {
176176
}
177177
}
178178

179+
export function shouldDetectPorts(): boolean {
180+
const config = workspace.getConfiguration('arduinoMakerWorkshop');
181+
const disableAutoPortDetection = config.get<boolean>('disableAutoPortDetection', false);
182+
183+
// Only disable port detection on Windows if the setting is enabled
184+
if (os.platform() === 'win32' && disableAutoPortDetection) {
185+
return false; // Skip port detection
186+
}
187+
188+
return true; // Proceed with port detection
189+
}
190+
179191
function changeUserDirectory() {
180192
const config = workspace.getConfiguration('arduinoMakerWorkshop.arduinoCLI');
181193
const userDirectory = config.get<string>('userDirectory', '');
182-
if(userDirectory.trim().length > 0) {
194+
if (userDirectory.trim().length > 0) {
183195
if (VueWebviewPanel.currentPanel) {
184196
VueWebviewPanel.currentPanel.dispose();
185197
VueWebviewPanel.currentPanel = undefined;
186198
}
187199
arduinoCLI.setConfigUserDirectory(userDirectory);
188200
arduinoCLI.clearLibraryCache();
189201
window.showInformationMessage(`User directory set to: ${userDirectory}`);
190-
}
202+
}
191203
}
192204

193205
function isWatchedExtension(filePath: string): boolean {

0 commit comments

Comments
 (0)