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

fix run selected text #180467

Merged
merged 1 commit into from Apr 21, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/vs/workbench/contrib/terminal/browser/terminalActions.ts
Expand Up @@ -502,7 +502,7 @@ export function registerTerminalActions() {
title: { value: localize('workbench.action.terminal.runSelectedText', "Run Selected Text In Active Terminal"), original: 'Run Selected Text In Active Terminal' },
run: async (c, accessor) => {
const codeEditorService = accessor.get(ICodeEditorService);
const instance = await c.service.getActiveOrCreateInstance();
let instance = await c.service.getActiveOrCreateInstance();
const editor = codeEditorService.getActiveCodeEditor();
if (!editor || !editor.hasModel()) {
return;
Expand All @@ -515,6 +515,12 @@ export function registerTerminalActions() {
const endOfLinePreference = isWindows ? EndOfLinePreference.LF : EndOfLinePreference.CRLF;
text = editor.getModel().getValueInRange(selection, endOfLinePreference);
}
// Don't use task terminals or other terminals that don't accept input
if (instance?.xterm?.isStdinDisabled || instance?.shellLaunchConfig.type === 'Task') {
instance = await c.service.createTerminal();
c.service.setActiveInstance(instance);
await revealActiveTerminal(instance, c);
}
instance.sendText(text, true, true);
await revealActiveTerminal(instance, c);
}
Expand Down