Skip to content

Commit 3612c22

Browse files
authored
SSH terminal for targets (#9895)
* SSH terminal for targets
1 parent 230bce9 commit 3612c22

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

Extension/package.json

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2970,6 +2970,12 @@
29702970
"category": "C/C++",
29712971
"title": "%c_cpp.command.refreshCppSshTargetsView.title%",
29722972
"icon": "$(refresh)"
2973+
},
2974+
{
2975+
"command": "C_Cpp.sshTerminal",
2976+
"category": "C/C++",
2977+
"title": "%c_cpp.command.sshTerminal.title%",
2978+
"icon": "$(terminal)"
29732979
}
29742980
],
29752981
"keybindings": [
@@ -5070,15 +5076,20 @@
50705076
}
50715077
],
50725078
"view/item/context": [
5073-
{
5074-
"command": "C_Cpp.removeSshTarget",
5075-
"when": "viewItem == CppSshTargetsView.targetLeafRemovable || viewItem == CppSshTargetsView.targetLeafRemovableCanSetActive",
5076-
"group": "inline@1"
5077-
},
50785079
{
50795080
"command": "C_Cpp.setActiveSshTarget",
50805081
"when": "viewItem == CppSshTargetsView.targetLeafCanSetActive || viewItem == CppSshTargetsView.targetLeafRemovableCanSetActive",
50815082
"group": "inline@0"
5083+
},
5084+
{
5085+
"command": "C_Cpp.sshTerminal",
5086+
"when": "view == CppSshTargetsView",
5087+
"group": "inline@1"
5088+
},
5089+
{
5090+
"command": "C_Cpp.removeSshTarget",
5091+
"when": "viewItem == CppSshTargetsView.targetLeafRemovable || viewItem == CppSshTargetsView.targetLeafRemovableCanSetActive",
5092+
"group": "inline@2"
50825093
}
50835094
],
50845095
"editor/title/run": [
@@ -5169,6 +5180,10 @@
51695180
{
51705181
"command": "C_Cpp.refreshCppSshTargetsView",
51715182
"when": "never"
5183+
},
5184+
{
5185+
"command": "C_Cpp.sshTerminal",
5186+
"when": "never"
51725187
}
51735188
]
51745189
},

Extension/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
"c_cpp.command.selectSshTarget.title": "Select SSH target",
3737
"c_cpp.command.activeSshTarget.title": "Get the active SSH target",
3838
"c_cpp.command.refreshCppSshTargetsView.title": "Refresh",
39+
"c_cpp.command.sshTerminal.title": "Connect to this SSH target in a new terminal",
3940
"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." ] },
4041
"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." ] },
4142
"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." ] },

Extension/src/Debugger/extension.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ export async function initialize(context: vscode.ExtensionContext): Promise<void
100100
}
101101
}));
102102
disposables.push(vscode.commands.registerCommand('C_Cpp.activeSshTarget', () => enableSshTargetsViewAndRun(getActiveSshTarget)));
103+
disposables.push(vscode.commands.registerCommand('C_Cpp.sshTerminal', (node: TargetLeafNode) => enableSshTargetsViewAndRun(sshTerminal, node)));
103104
disposables.push(sshTargetsProvider);
104105

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

134+
function sshTerminal(node: TargetLeafNode): void {
135+
const terminal: vscode.Terminal = vscode.window.createTerminal(`SSH: ${node.name}`);
136+
terminal.sendText(`ssh "${node.name}"`);
137+
terminal.show();
138+
}
139+
133140
async function enableSshTargetsViewAndRun<T>(func: (...paras: any[]) => T | Promise<T>, ...args: any[]): Promise<T> {
134141
await enableSshTargetsView();
135142
return func(...args);

0 commit comments

Comments
 (0)