mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-20 16:49:06 +01:00
web worker: support F5 debugging w/o launch.config
This commit is contained in:
@@ -896,6 +896,7 @@ export class MemFS implements vscode.FileSystemProvider, vscode.FileSearchProvid
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
function enableDebug(context: vscode.ExtensionContext, memFs: MemFS): void {
|
||||
context.subscriptions.push(vscode.debug.registerDebugConfigurationProvider('mock', new MockConfigurationProvider()));
|
||||
context.subscriptions.push(vscode.debug.registerDebugAdapterDescriptorFactory('mock', new MockDebugAdapterDescriptorFactory(memFs)));
|
||||
}
|
||||
|
||||
@@ -3796,12 +3797,34 @@ export class Handles<T> {
|
||||
|
||||
//---------------------------------------------------------------------------
|
||||
|
||||
function basename(path: string): string {
|
||||
const pos = path.lastIndexOf('/');
|
||||
if (pos >= 0) {
|
||||
return path.substring(pos + 1);
|
||||
class MockConfigurationProvider implements vscode.DebugConfigurationProvider {
|
||||
|
||||
/**
|
||||
* Massage a debug configuration just before a debug session is being launched,
|
||||
* e.g. add all missing attributes to the debug configuration.
|
||||
*/
|
||||
resolveDebugConfiguration(_folder: vscode.WorkspaceFolder | undefined, config: vscode.DebugConfiguration, _token?: vscode.CancellationToken): vscode.ProviderResult<vscode.DebugConfiguration> {
|
||||
|
||||
// if launch.json is missing or empty
|
||||
if (!config.type && !config.request && !config.name) {
|
||||
const editor = vscode.window.activeTextEditor;
|
||||
if (editor && editor.document.languageId === 'markdown') {
|
||||
config.type = 'mock';
|
||||
config.name = 'Launch';
|
||||
config.request = 'launch';
|
||||
config.program = '${file}'; // editor.document.fileName; // '${file}';
|
||||
config.stopOnEntry = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!config.program) {
|
||||
return vscode.window.showInformationMessage('Cannot find a program to debug').then(_ => {
|
||||
return undefined; // abort launch
|
||||
});
|
||||
}
|
||||
|
||||
return config;
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
export class MockDebugAdapterDescriptorFactory implements vscode.DebugAdapterDescriptorFactory {
|
||||
@@ -3818,6 +3841,14 @@ export class MockDebugAdapterDescriptorFactory implements vscode.DebugAdapterDes
|
||||
}
|
||||
}
|
||||
|
||||
function basename(path: string): string {
|
||||
const pos = path.lastIndexOf('/');
|
||||
if (pos >= 0) {
|
||||
return path.substring(pos + 1);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
function timeout(ms: number) {
|
||||
return new Promise(resolve => setTimeout(resolve, ms));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user