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