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

SSH terminal for targets #9895

Merged
merged 4 commits into from
Sep 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions Extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2970,6 +2970,12 @@
"category": "C/C++",
"title": "%c_cpp.command.refreshCppSshTargetsView.title%",
"icon": "$(refresh)"
},
{
"command": "C_Cpp.sshTerminal",
"category": "C/C++",
"title": "%c_cpp.command.sshTerminal.title%",
"icon": "$(terminal)"
}
],
"keybindings": [
Expand Down Expand Up @@ -5070,15 +5076,20 @@
}
],
"view/item/context": [
{
"command": "C_Cpp.removeSshTarget",
"when": "viewItem == CppSshTargetsView.targetLeafRemovable || viewItem == CppSshTargetsView.targetLeafRemovableCanSetActive",
"group": "inline@1"
},
{
"command": "C_Cpp.setActiveSshTarget",
"when": "viewItem == CppSshTargetsView.targetLeafCanSetActive || viewItem == CppSshTargetsView.targetLeafRemovableCanSetActive",
"group": "inline@0"
},
{
xisui-MSFT marked this conversation as resolved.
Show resolved Hide resolved
"command": "C_Cpp.sshTerminal",
"when": "view == CppSshTargetsView",
"group": "inline@1"
},
{
"command": "C_Cpp.removeSshTarget",
"when": "viewItem == CppSshTargetsView.targetLeafRemovable || viewItem == CppSshTargetsView.targetLeafRemovableCanSetActive",
"group": "inline@2"
}
],
"editor/title/run": [
Expand Down Expand Up @@ -5169,6 +5180,10 @@
{
"command": "C_Cpp.refreshCppSshTargetsView",
"when": "never"
},
{
"command": "C_Cpp.sshTerminal",
"when": "never"
}
]
},
Expand Down
1 change: 1 addition & 0 deletions Extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"c_cpp.command.selectSshTarget.title": "Select SSH target",
"c_cpp.command.activeSshTarget.title": "Get the active SSH target",
"c_cpp.command.refreshCppSshTargetsView.title": "Refresh",
"c_cpp.command.sshTerminal.title": "Connect to this SSH target in a new terminal",
"c_cpp.configuration.maxConcurrentThreads.markdownDescription": { "message": "The maximum number of concurrent threads to use for language service processing. The value is a hint and may not always be used. The default of `null` (empty) uses the number of logical processors available.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
"c_cpp.configuration.maxCachedProcesses.markdownDescription": { "message": "The maximum number of cached processes to use for language service processing. The default of `null` (empty) uses twice the number of logical processors available.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
"c_cpp.configuration.maxMemory.markdownDescription": { "message": "The maximum memory (in MB) available for language service processing. Fewer processes will be cached and run concurrently after this memory usage is exceeded. The default of `null` (empty) uses the system's free memory.", "comment": [ "Markdown text between `` should not be translated or localized (they represent literal text) and the capitalization, spacing, and punctuation (including the ``) should not be altered." ] },
Expand Down
7 changes: 7 additions & 0 deletions Extension/src/Debugger/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export async function initialize(context: vscode.ExtensionContext): Promise<void
}
}));
disposables.push(vscode.commands.registerCommand('C_Cpp.activeSshTarget', () => enableSshTargetsViewAndRun(getActiveSshTarget)));
disposables.push(vscode.commands.registerCommand('C_Cpp.sshTerminal', (node: TargetLeafNode) => enableSshTargetsViewAndRun(sshTerminal, node)));
disposables.push(sshTargetsProvider);

// Decide if we should show the SSH Targets View.
Expand Down Expand Up @@ -130,6 +131,12 @@ export function dispose(): void {
disposables.forEach(d => d.dispose());
}

function sshTerminal(node: TargetLeafNode): void {
const terminal: vscode.Terminal = vscode.window.createTerminal(`SSH: ${node.name}`);
terminal.sendText(`ssh "${node.name}"`);
terminal.show();
}

async function enableSshTargetsViewAndRun<T>(func: (...paras: any[]) => T | Promise<T>, ...args: any[]): Promise<T> {
await enableSshTargetsView();
return func(...args);
Expand Down