Skip to content

Commit d94629c

Browse files
authored
Support servers defined at the workspace-folder level for launching Lite Terminal from Servers tree view (#1617)
1 parent d60ad40 commit d94629c

File tree

2 files changed

+20
-8
lines changed

2 files changed

+20
-8
lines changed

src/commands/webSocketTerminal.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
9696
// eslint-disable-next-line no-control-regex
9797
private _colorsRegex = /\x1b[^m]*?m/g;
9898

99-
constructor(private readonly _targetUri: vscode.Uri) {}
99+
constructor(
100+
private readonly _targetUri: vscode.Uri,
101+
private readonly _nsOverride?: string
102+
) {}
100103

101104
/** Hide the cursor, write `data` to the terminal, then show the cursor again. */
102105
private _hideCursorWrite(data: string): void {
@@ -201,6 +204,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
201204

202205
open(initialDimensions?: vscode.TerminalDimensions): void {
203206
const api = new AtelierAPI(this._targetUri);
207+
if (this._nsOverride) api.setNamespace(this._nsOverride);
204208
this._cols = initialDimensions?.columns ?? 100000;
205209
try {
206210
// Open the WebSocket
@@ -728,7 +732,8 @@ function reportError(msg: string, throwErrors = false) {
728732
function terminalConfigForUri(
729733
api: AtelierAPI,
730734
targetUri: vscode.Uri,
731-
throwErrors = false
735+
throwErrors: boolean,
736+
nsOverride?: string
732737
): vscode.ExtensionTerminalOptions | undefined {
733738
// Make sure the server connection is active
734739
if (!api.active || api.ns == "") {
@@ -751,13 +756,13 @@ function terminalConfigForUri(
751756
vscode.window.terminals.length > 0
752757
? vscode.TerminalLocation.Editor
753758
: vscode.TerminalLocation.Panel,
754-
pty: new WebSocketTerminal(targetUri),
759+
pty: new WebSocketTerminal(targetUri, nsOverride),
755760
isTransient: true,
756761
iconPath: iscIcon,
757762
};
758763
}
759764

760-
export async function launchWebSocketTerminal(targetUri?: vscode.Uri): Promise<void> {
765+
export async function launchWebSocketTerminal(targetUri?: vscode.Uri, nsOverride?: string): Promise<void> {
761766
// Determine the server to connect to
762767
if (targetUri) {
763768
// Uri passed as command argument might be for a server we haven't yet resolved
@@ -779,7 +784,7 @@ export async function launchWebSocketTerminal(targetUri?: vscode.Uri): Promise<v
779784
await api.serverInfo();
780785

781786
// Get the terminal configuration
782-
const terminalOpts = terminalConfigForUri(api, targetUri);
787+
const terminalOpts = terminalConfigForUri(api, targetUri, false, nsOverride);
783788
if (terminalOpts) {
784789
// Launch the terminal
785790
const terminal = vscode.window.createTerminal(terminalOpts);

src/extension.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1709,10 +1709,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
17091709
(namespaceTreeItem) => {
17101710
sendCommandTelemetryEvent("intersystems-servermanager.webterminal");
17111711
const idArray = namespaceTreeItem.id.split(":");
1712-
const serverId = idArray[1];
17131712
const namespace = idArray[3];
1714-
const targetUri = vscode.Uri.from({ scheme: "isfs", authority: `${serverId}:${namespace}` });
1715-
launchWebSocketTerminal(targetUri);
1713+
const serverTreeItem = namespaceTreeItem?.parent?.parent;
1714+
const isWsFolderServer =
1715+
serverTreeItem?.label.includes("(") && typeof serverTreeItem?.params?.serverSummary?.scope?.uri == "object";
1716+
launchWebSocketTerminal(
1717+
// Support servers that are defined at the workspace-folder level
1718+
isWsFolderServer
1719+
? serverTreeItem?.params?.serverSummary?.scope?.uri
1720+
: vscode.Uri.from({ scheme: "isfs", authority: `${idArray[1]}:${namespace}` }),
1721+
isWsFolderServer ? namespace : undefined
1722+
);
17161723
}
17171724
),
17181725
vscode.commands.registerCommand("vscode-objectscript.ObjectScriptExplorer.webterminal", (node: NodeBase) => {

0 commit comments

Comments
 (0)