Skip to content

Add command to copy output of the last command (#152097)#153235

Merged
meganrogge merged 2 commits into
microsoft:mainfrom
MonadChains:copy-last-output
Jul 7, 2022
Merged

Add command to copy output of the last command (#152097)#153235
meganrogge merged 2 commits into
microsoft:mainfrom
MonadChains:copy-last-output

Conversation

@MonadChains
Copy link
Copy Markdown
Contributor

This PR fixes #152097

@Tyriar Tyriar added this to the July 2022 milestone Jun 27, 2022
@Tyriar Tyriar assigned meganrogge and unassigned meganrogge Jul 5, 2022
const commands = cmdDetection?.commands;
if (commands && commands.length > 0) {
const output = commands[commands.length - 1]?.getOutput();
if (output) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getOutput will return undefined if the last command that was run is in the scrollback, so I don't think this will work for the case you're interested in

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should only be if it's trimmed from the scrollback, so if the command decoration is there it should always have getOutput().

Copy link
Copy Markdown
Contributor

@Tyriar Tyriar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @MonadChains, it worked great. I added some minor tweaks and checked hasOutput before getOutput as well.

Will merge this after #154220 goes in for the conflict

@meganrogge meganrogge merged commit d5d6e08 into microsoft:main Jul 7, 2022
@MonadChains MonadChains deleted the copy-last-output branch July 19, 2022 00:37
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Easily copy result of last command without having the command still in view

3 participants