MCPcopy
hub / github.com/microsoft/vscode-js-debug / launchTerminal

Function launchTerminal

src/ui/debugTerminalUI.ts:227–289  ·  view source on GitHub ↗

* See docblocks on DelegateLauncher for more information on * how this works.

(
    delegate: DelegateLauncherFactory,
    command?: string,
    workspaceFolder?: vscode.WorkspaceFolder,
    defaultConfig?: Partial<ITerminalLaunchConfiguration>,
    createLauncherFn = createLauncher,
  )

Source from the content-addressed store, hash-verified

225 * how this works.
226 */
227 async function launchTerminal(
228 delegate: DelegateLauncherFactory,
229 command?: string,
230 workspaceFolder?: vscode.WorkspaceFolder,
231 defaultConfig?: Partial<ITerminalLaunchConfiguration>,
232 createLauncherFn = createLauncher,
233 ) {
234 if (!workspaceFolder) {
235 const picked = await getWorkspaceFolder();
236 if (picked === Abort) {
237 return;
238 }
239
240 workspaceFolder = picked;
241 }
242
243 // try to reuse a terminal if invoked programmatically to run a command
244 if (command) {
245 for (const [terminal, config] of terminals) {
246 if (
247 config.folder === workspaceFolder
248 && config.cwd === defaultConfig?.cwd
249 && !config.launcher.targetList().length
250 ) {
251 terminal.show(true);
252 terminal.sendText(command);
253 return;
254 }
255 }
256 }
257
258 const logger = new ProxyLogger();
259 const launcher = createLauncherFn(
260 logger,
261 new NodeBinaryProvider(logger, services.get(FS), noPackageJsonProvider, {}),
262 );
263
264 launcher.onTerminalCreated(terminal => {
265 terminals.set(terminal, { launcher, folder: workspaceFolder, cwd: defaultConfig?.cwd });
266 });
267
268 try {
269 await launchVirtualTerminalParent(
270 delegate,
271 launcher,
272 {
273 command,
274 ...defaultConfig,
275 __workspaceFolder: workspaceFolder?.uri.fsPath,
276 },
277 () => {
278 for (const [terminal, rec] of terminals) {
279 if (rec.launcher === launcher && terminal.state.isInteractedWith) {
280 return true;
281 }
282 }
283 return false;
284 },

Callers 1

registerDebugTerminalUIFunction · 0.85

Calls 7

getWorkspaceFolderFunction · 0.85
sendTextMethod · 0.80
targetListMethod · 0.65
showMethod · 0.65
getMethod · 0.65
setMethod · 0.65

Tested by

no test coverage detected