From abf054e7eb7dd24fbd9e04f1c769012f2b3319b0 Mon Sep 17 00:00:00 2001 From: "Mr.Santiaga" Date: Sat, 8 Feb 2020 13:50:27 +0300 Subject: [PATCH] Use trySetOpenedFileAsSketch() method Here is 2 changes: - Subscrube to event onDidChangeActiveTextEditor to set "sketch" value into arduino.json when useActiveSketch option is true - Don't show sketch name in Status Bar when "sketch" value is atomatically setted in arduino.json --- src/deviceContext.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/deviceContext.ts b/src/deviceContext.ts index 9600e872..4e34af16 100644 --- a/src/deviceContext.ts +++ b/src/deviceContext.ts @@ -115,6 +115,9 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable { this._sketchStatusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, constants.statusBarPriority.SKETCH); this._sketchStatusBar.command = "arduino.setSketchFile"; this._sketchStatusBar.tooltip = "Sketch File"; + vscode.window.onDidChangeActiveTextEditor(()=>{ + this.trySetOpenedFileAsSketch(); + }) } } @@ -194,6 +197,10 @@ export class DeviceContext implements IDeviceContext, vscode.Disposable { } public showStatusBar() { + if(this.trySetOpenedFileAsSketch()){ + return; + } + if (!this._sketch) { return false; }