Working properly, making term when needed or reusing

This commit is contained in:
Earle F. Philhower, III
2023-09-28 16:35:42 -07:00
parent 7fea1340b1
commit 66aff046cf
2 changed files with 7 additions and 11 deletions

Binary file not shown.

View File

@ -9,12 +9,11 @@ let writerReady : boolean = false;
function makeTerminal(title : string) {
// If it exists, move it to the front
vscode.window.terminals.forEach( (w) => {
if (w.name === title) {
let w = vscode.window.terminals.find( (w) => ((w.name === title) && (w.exitStatus === undefined)));
if (w !== undefined) {
w.show(false);
return;
}
});
// Not found, make a new terminal
const pty = {
onDidWrite: writeEmitter.event,
@ -40,8 +39,6 @@ function findTool(ctx: ArduinoContext, match : string) : string | undefined {
return ret;
}
export function activate(context: vscode.ExtensionContext) {
// Get the Arduino info extension loaded
const arduinoContext: ArduinoContext = vscode.extensions.getExtension('dankeboy36.vscode-arduino-api')?.exports;
@ -51,8 +48,6 @@ export function activate(context: vscode.ExtensionContext) {
return;
}
makeTerminal("LittleFS Upload");
// Register the command
const disposable = vscode.commands.registerCommand('arduino-littlefs-upload.uploadLittleFS', async () => {
@ -64,6 +59,7 @@ export function activate(context: vscode.ExtensionContext) {
return;
}
makeTerminal("LittleFS Upload");
// Wait for the terminal to become active.
while (!writerReady) {
await new Promise( resolve => setTimeout(resolve, 100) );
@ -246,4 +242,4 @@ export function activate(context: vscode.ExtensionContext) {
context.subscriptions.push(disposable);
}
export function deactivate() {}
export function deactivate() { }