Skip to content

Commit d60ad40

Browse files
authored
Remove _api property from Lite Terminal implementation (#1610)
1 parent b5f1df6 commit d60ad40

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

src/commands/webSocketTerminal.ts

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ 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 _api: AtelierAPI) {}
99+
constructor(private readonly _targetUri: vscode.Uri) {}
100100

101101
/** Hide the cursor, write `data` to the terminal, then show the cursor again. */
102102
private _hideCursorWrite(data: string): void {
@@ -140,12 +140,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
140140

141141
/** Checks if syntax coloring is enabled */
142142
private _syntaxColoringEnabled(): boolean {
143-
return vscode.workspace
144-
.getConfiguration(
145-
"objectscript.webSocketTerminal",
146-
vscode.workspace.getWorkspaceFolder(this._api.wsOrFile instanceof vscode.Uri ? this._api.wsOrFile : undefined)
147-
)
148-
.get("syntaxColoring");
143+
return vscode.workspace.getConfiguration("objectscript.webSocketTerminal").get("syntaxColoring");
149144
}
150145

151146
/**
@@ -205,13 +200,14 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
205200
}
206201

207202
open(initialDimensions?: vscode.TerminalDimensions): void {
203+
const api = new AtelierAPI(this._targetUri);
208204
this._cols = initialDimensions?.columns ?? 100000;
209205
try {
210206
// Open the WebSocket
211-
this._socket = new WebSocket(this._api.terminalUrl(), {
207+
this._socket = new WebSocket(api.terminalUrl(), {
212208
rejectUnauthorized: vscode.workspace.getConfiguration("http").get("proxyStrictSSL"),
213209
headers: {
214-
cookie: this._api.cookies,
210+
cookie: api.cookies,
215211
},
216212
});
217213
} catch (error) {
@@ -224,7 +220,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
224220
this._hideCursorWrite("\x1b]633;P;HasRichCommandDetection=True\x07");
225221
// Print the opening message
226222
this._hideCursorWrite(
227-
`\x1b[32mConnected to \x1b[0m\x1b[4m${this._api.config.host}:${this._api.config.port}${this._api.config.pathPrefix}\x1b[0m\x1b[32m as \x1b[0m\x1b[3m${this._api.config.username}\x1b[0m\r\n\r\n`
223+
`\x1b[32mConnected to \x1b[0m\x1b[4m${api.config.host}:${api.config.port}${api.config.pathPrefix}\x1b[0m\x1b[32m as \x1b[0m\x1b[3m${api.config.username}\x1b[0m\r\n\r\n`
228224
);
229225
// Add event handlers to the socket
230226
this._socket
@@ -289,7 +285,7 @@ class WebSocketTerminal implements vscode.Pseudoterminal {
289285
JSON.stringify({
290286
type: "config",
291287
// Start in the current namespace
292-
namespace: this._api.ns,
288+
namespace: api.ns,
293289
// Have the server send ANSI escape codes since we can print them
294290
rawMode: false,
295291
})
@@ -755,7 +751,7 @@ function terminalConfigForUri(
755751
vscode.window.terminals.length > 0
756752
? vscode.TerminalLocation.Editor
757753
: vscode.TerminalLocation.Panel,
758-
pty: new WebSocketTerminal(api),
754+
pty: new WebSocketTerminal(targetUri),
759755
isTransient: true,
760756
iconPath: iscIcon,
761757
};

0 commit comments

Comments
 (0)