MCPcopy Index your code
hub / github.com/microsoft/vscode-js-debug / registerDebugTerminalUI

Function registerDebugTerminalUI

src/ui/debugTerminalUI.ts:202–321  ·  view source on GitHub ↗
(
  context: vscode.ExtensionContext,
  delegateFactory: DelegateLauncherFactory,
  services: Container,
)

Source from the content-addressed store, hash-verified

200 * Registers a command to launch the debugger terminal.
201 */
202export function registerDebugTerminalUI(
203 context: vscode.ExtensionContext,
204 delegateFactory: DelegateLauncherFactory,
205 services: Container,
206) {
207 const terminals = new Map<
208 vscode.Terminal,
209 { launcher: TerminalNodeLauncher; folder?: vscode.WorkspaceFolder; cwd?: string }
210 >();
211
212 const createLauncher = (logger: ProxyLogger, binary: NodeBinaryProvider) =>
213 new TerminalNodeLauncher(
214 binary,
215 logger,
216 services.get(FS),
217 services.get(NodeOnlyPathResolverFactory),
218 services.get(IPortLeaseTracker),
219 services.get(IDebugTerminalOptionsProviders),
220 services.get(ITerminalLinkProvider),
221 );
222
223 /**
224 * See docblocks on {@link DelegateLauncher} for more information on
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(

Callers 1

activateFunction · 0.90

Calls 6

registerCommandFunction · 0.90
launchTerminalFunction · 0.85
resolveFunction · 0.85
pushMethod · 0.65
deleteMethod · 0.65
getMethod · 0.65

Tested by

no test coverage detected