Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implementing Terminal: Run Recent Commad when there are no open terminal #234124

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

SalerSimo
Copy link

@SalerSimo SalerSimo commented Nov 18, 2024

Fix #233604
The command 'Terminal: Run Recent Command' will now create a new terminal if no terminals are currently open.

Simply creating a new terminal is not sufficient for the recent command window to display correctly.
When a new terminal is created, it looks like it takes some more time to fully update its related variables, so I inserted a loop of quick sleep functions (up to 5 seconds in total) while continuosly trying to display the recent command window.

@SalerSimo
Copy link
Author

@microsoft-github-policy-service agree

Copy link
Member

@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.

I don't think we should be doing anything outside of the command implementation. Everything you need to do should be able to be done there. You might need to change it to registerTerminalAction instead in order to get it to run when a terminal doesn't actually exist yet.

Comment on lines 252 to 263
run: async (c, accessor, args) => {
let activeInstance = c.service.activeInstance;
const id = options.id;
if (activeInstance) {
return originalRun(activeInstance, c, accessor, args);
}
if (id !== 'workbench.action.terminal.runRecentCommand') {
return;
}
const commandService = accessor.get(ICommandService);
await commandService.executeCommand('workbench.action.terminal.new');
activeInstance = c.service.activeInstance;
Copy link
Member

Choose a reason for hiding this comment

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

This is a generic function so you shouldn't be changing this, instead you should change the run callback passed in when it's called.

@SalerSimo
Copy link
Author

@Tyriar I changed it in order to avoid changing the generic function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Terminal: Run Recent Command shows up when there are no terminals
2 participants