Skip to content
This repository was archived by the owner on Sep 17, 2021. It is now read-only.

Commit 2f39865

Browse files
committed
Update to logic for detecting url to attach to
1 parent df2e937 commit 2f39865

File tree

2 files changed

+27
-11
lines changed

2 files changed

+27
-11
lines changed

package.json

Lines changed: 22 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,35 @@
5959
"label": "DevTools for Chrome",
6060
"configurationAttributes": {
6161
"launch": {
62-
"required": [
63-
"url"
64-
],
6562
"properties": {
6663
"url": {
6764
"type": "string",
6865
"description": "Absolute uri to launch.",
6966
"default": "http://localhost:8080"
7067
},
71-
"request": {
68+
"file": {
7269
"type": "string",
73-
"description": "A value representing whether the debugger should launch a new Chrome tab or attach to an exsisting one.",
74-
"default": "launch"
70+
"description": "File path to launch.",
71+
"default": "${workspaceFolder}/index.html"
72+
},
73+
"chromePath": {
74+
"type": "string",
75+
"description": "Absolute path to the Chrome instance to launch.",
76+
"default": ""
77+
}
78+
}
79+
},
80+
"attach": {
81+
"properties": {
82+
"url": {
83+
"type": "string",
84+
"description": "Absolute uri to launch.",
85+
"default": "http://localhost:8080"
86+
},
87+
"file": {
88+
"type": "string",
89+
"description": "File path to launch.",
90+
"default": "${workspaceFolder}/index.html"
7591
},
7692
"chromePath": {
7793
"type": "string",

src/extension.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function activate(context: vscode.ExtensionContext) {
4949
if (config && config.type == debuggerType) {
5050
let targetUri: string = utils.getUrlFromConfig(folder, config);
5151
if (config.request && config.request.localeCompare('attach', 'en', { sensitivity: 'base' }) == 0) {
52-
attach(context, /* viaConfig= */ true, defaultUrl);
52+
attach(context, /* viaConfig= */ true, targetUri);
5353
} else if (config.request && config.request.localeCompare('launch', 'en', { sensitivity: 'base' }) == 0) {
5454
launch(context, targetUri, config.chromePath);
5555
}
@@ -112,20 +112,20 @@ async function attach(context: vscode.ExtensionContext, viaConfig: boolean, targ
112112
});
113113
});
114114

115-
let targetUrl: string = '';
116115
let targetMatch:boolean = false;
116+
let targetWebsocketUrl:string = '';
117117
if (typeof targetUrl === 'string' && targetUrl.length > 0 && targetUrl != defaultUrl) {
118-
const matches = items.filter(i => i.description == defaultUrl);
118+
const matches = items.filter(i => targetUrl.localeCompare(i.description, 'en', { sensitivity: 'base' }) == 0);
119119
if(matches && matches.length > 0 ){
120-
targetUrl = matches[0].description;
120+
targetWebsocketUrl = matches[0].detail;
121121
targetMatch = true;
122122
} else {
123123
vscode.window.showErrorMessage(`Couldn't attach to ${targetUrl}.`);
124124
}
125125
}
126126

127127
if(targetMatch){
128-
DevToolsPanel.createOrShow(context, targetUrl as string);
128+
DevToolsPanel.createOrShow(context, targetWebsocketUrl as string);
129129
} else {
130130
vscode.window.showQuickPick(items).then((selection) => {
131131
if (selection) {

0 commit comments

Comments
 (0)