693
break;
694
}
696
>
case Osc633EventType.CommandExecuted: {
697
>
const commandId = `cmd-${++tracker.commandCounter}`;
698
>
const commandLine = tracker.pendingCommandLine ?? '';
699
>
const timestamp = Date.now();
700
>
tracker.pendingCommandLine = undefined;
701
>
tracker.activeCommandId = commandId;
702
>
tracker.activeCommandTimestamp = timestamp;
703
>
704
>
// Push a new command content part
705
>
managed.content.push({
706
>
type: 'command',
707
>
commandId,
708
>
commandLine,
709
>
output: '',
710
>
timestamp,
711
>
isComplete: false,
712
>
});
713
>
714
>
this._stateManager.dispatchServerAction(managed.uri, {
715
>
type: ActionType.TerminalCommandExecuted,
716
>
commandId,
717
>
commandLine,
718
>
timestamp,
719
>
});
720
>
break;
721
>
}
722
>
723
>
case Osc633EventType.CommandFinished: {
724
>
const finishedCommandId = tracker.activeCommandId;
725
>
if (!finishedCommandId) {
726
break;
727
}
729
>
? Date.now() - tracker.activeCommandTimestamp
730
: undefined;
732
>
// Mark the command content part as complete and collect output
733
>
let commandLine = '';
734
>
let commandOutput = '';
735
>
for (const part of managed.content) {
736
>
if (part.type === 'command' && part.commandId === finishedCommandId) {
737
>
part.isComplete = true;
738
>
part.exitCode = event.exitCode;
739
>
part.durationMs = durationMs;
740
>
commandLine = part.commandLine;
741
>
commandOutput = part.output;
742
>
break;
743
>
}
744
>
}
745
>
746
>
tracker.activeCommandId = undefined;
747
>
tracker.activeCommandTimestamp = undefined;
748
>
749
>
managed.onCommandFinishedEmitter.fire({
750
>
commandId: finishedCommandId,
751
>
exitCode: event.exitCode,
752
>
command: commandLine,
753
>
output: commandOutput,
754
>
});
755
>
756
>
this._stateManager.dispatchServerAction(managed.uri, {
757
>
type: ActionType.TerminalCommandFinished,
758
>
commandId: finishedCommandId,
759
>
exitCode: event.exitCode,
760
>
durationMs,
761
>
});
762
>
break;
763
>
}
764
>
765
>
case Osc633EventType.Property: {
766
if (event.key === 'Cwd') {
767
managed.cwd = event.value;