diff --git a/src/communicationmanager.ts b/src/communicationmanager.ts index d6bc8db..3cb798f 100644 --- a/src/communicationmanager.ts +++ b/src/communicationmanager.ts @@ -63,8 +63,11 @@ export class CommunicationManager { "Sending script to terminal", ) }, - (reason) => { - void vscode.window.showErrorMessage(reason as string) + (error: unknown) => { + const err_msg = (error as Error).message + void vscode.window.showErrorMessage( + "Unable to send script to terminal. Error: " + err_msg, + ) }, ) } @@ -134,8 +137,8 @@ export class CommunicationManager { () => { isConnSuccessful = true }, - (reason) => { - err_msg = reason as string + (error: unknown) => { + err_msg = (error as Error).message isConnSuccessful = false }, ) diff --git a/src/instruments.ts b/src/instruments.ts index fb49e86..4d990d1 100644 --- a/src/instruments.ts +++ b/src/instruments.ts @@ -824,10 +824,11 @@ export class NewTDPModel { //check for redundant entries public addToConnectionList(instr: InstrInfo) { - let res: InstrInfo | undefined = undefined let idx = -1 + let status = "add_new" if (this.connection_list.length == 0) { this.connection_list.push(instr) + return } else { for (let i = 0; i < this.connection_list.length; i++) { if ( @@ -839,23 +840,20 @@ export class NewTDPModel { instr.instr_address ) { idx = i - res = instr + status = "update" break } else { + status = "no_change" break } - } else { - res = instr } } } - if (res != undefined) { - if (idx > -1) { - this.connection_list[idx] = res - } else { - this.connection_list.push(res) - } + if (status == "add_new") { + this.connection_list.push(instr) + } else if (status == "update") { + this.connection_list[idx] = instr } }