Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

settings: adding autoStartBrowserURL setting to customize the URL tha… #581

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -373,6 +373,10 @@
"description": "Open external browser to launch the application",
"type": "boolean"
},
"autoStartBrowserURL": {
"description": "The URL to open in the external browser if autoStartBrowser is true. The URL can be a regular expression that matches the URL to open in the stdout.",
"type": "string"
},
"django": {
"default": false,
"description": "Django debugging.",
Expand Down
1 change: 1 addition & 0 deletions src/extension/debugger/configuration/resolvers/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ export abstract class BaseConfigurationResolver<T extends DebugConfiguration>
showReturnValue: !!debugConfiguration.showReturnValue,
subProcess: !!debugConfiguration.subProcess,
autoStartBrowser: !!debugConfiguration,
autoStartBrowserURL: debugConfiguration.autoStartBrowserURL,
watson: name.toLowerCase().indexOf('watson') >= 0,
pyspark: name.toLowerCase().indexOf('pyspark') >= 0,
gevent: name.toLowerCase().indexOf('gevent') >= 0,
Expand Down
6 changes: 5 additions & 1 deletion src/extension/debugger/configuration/resolvers/launch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,12 @@ export class LaunchConfigurationResolver extends BaseConfigurationResolver<Launc
const isFastAPI = LaunchConfigurationResolver.isDebuggingFastAPI(debugConfiguration);
const isFlask = LaunchConfigurationResolver.isDebuggingFlask(debugConfiguration);
if (debugConfiguration.autoStartBrowser && (debugConfiguration.django || isFlask)) {
let pattern = '.*(?:(http|https):\\/\\/\\S+:[0-9]+\\/?).*';
if (debugConfiguration.autoStartBrowserURL !== undefined) {
pattern = `.*(${debugConfiguration.autoStartBrowserURL}).*`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is the reasoning behind having the .* appended here instead of just having the user submit the exact string match they want in the setting? This feels like it might confuse people if they manual configure with the starting * on their own

}
debugConfiguration.serverReadyAction = {
pattern: '.*(https?:\\/\\/\\S+:[0-9]+\\/?).*',
pattern: pattern,
uriFormat: '%s',
action: 'openExternally',
};
Expand Down
6 changes: 6 additions & 0 deletions src/extension/telemetry/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,12 @@ export interface IEventNamePropertyMapping {
* @type {boolean}
*/
autoStartBrowser: boolean;
/**
* A custom URL to start in the browser when autoStartBrowser is true.
*
* @type {string}
*/
autoStartBrowserURL: string;
};
/**
* Telemetry event sent when attaching to child process
Expand Down