(dataWrite: vscode.TerminalDataWriteEvent)
| 344 | }; |
| 345 | |
| 346 | const handleTerminalOutput = async (dataWrite: vscode.TerminalDataWriteEvent): Promise<void> => { |
| 347 | if (loggingLevel > 0) { |
| 348 | handleOutputLogging(dataWrite.data); |
| 349 | } |
| 350 | |
| 351 | if (continueWithoutExiting) { |
| 352 | // Skip the interactors after we have continued since I haven't see a use case for now. |
| 353 | return; |
| 354 | } |
| 355 | |
| 356 | stdout += dataWrite.data; |
| 357 | |
| 358 | if (interactors) { |
| 359 | for (const interactor of interactors) { |
| 360 | try { |
| 361 | const interaction: IInteraction = await interactor.onData(stdout); |
| 362 | |
| 363 | if (interaction.postAction === 'consume') { |
| 364 | if (args.usedInteractors) { |
| 365 | args.usedInteractors.add(interactor.id); |
| 366 | } |
| 367 | |
| 368 | stdout = ''; |
| 369 | } |
| 370 | |
| 371 | if (interaction.canceled) { |
| 372 | if (args.usedInteractors) { |
| 373 | args.usedInteractors.add(interactor.id); |
| 374 | } |
| 375 | |
| 376 | done(true); |
| 377 | return; |
| 378 | } |
| 379 | |
| 380 | if (interaction.continue) { |
| 381 | if (args.usedInteractors) { |
| 382 | args.usedInteractors.add(interactor.id); |
| 383 | } |
| 384 | continueWithoutExiting = true; |
| 385 | done(false, true); |
| 386 | return; |
| 387 | } |
| 388 | |
| 389 | if (typeof interaction.response === 'string') { |
| 390 | if (args.usedInteractors) { |
| 391 | args.usedInteractors.add(interactor.id); |
| 392 | } |
| 393 | |
| 394 | if (terminal) { |
| 395 | terminal.sendText(`${interaction.response}\n`); |
| 396 | const logOutput: string = interaction.isPassword |
| 397 | ? interaction.response.replace(/./g, '*') |
| 398 | : interaction.response; |
| 399 | if (loggingLevel >= 5) { |
| 400 | getSshChannel().appendLine(localize('ssh.wrote.data.to.terminal', '"{0}" wrote data to terminal: "{1}".', nickname, logOutput)); |
| 401 | } |
| 402 | } |
| 403 | } |
no test coverage detected