Skip to content

Commit ffbcbce

Browse files
authored
Add a serverReadyAction.action to open the URI in the Viewer pane (#4554)
Addresses #4553. See the issue for QA notes.
1 parent 1a983ce commit ffbcbce

File tree

4 files changed

+54
-1
lines changed

4 files changed

+54
-1
lines changed

extensions/debug-server-ready/package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,43 @@
7272
}
7373
}
7474
},
75+
{
76+
"type": "object",
77+
"additionalProperties": false,
78+
"markdownDescription": "%debug.server.ready.serverReadyAction.description%",
79+
"default": {
80+
"action": "openInViewer",
81+
"killOnServerStop": false
82+
},
83+
"properties": {
84+
"action": {
85+
"type": "string",
86+
"enum": [
87+
"openInViewer"
88+
],
89+
"enumDescriptions": [
90+
"%debug.server.ready.action.openInViewer.description%"
91+
],
92+
"markdownDescription": "%debug.server.ready.action.description%",
93+
"default": "openInViewer"
94+
},
95+
"pattern": {
96+
"type": "string",
97+
"markdownDescription": "%debug.server.ready.pattern.description%",
98+
"default": "listening on port ([0-9]+)"
99+
},
100+
"uriFormat": {
101+
"type": "string",
102+
"markdownDescription": "%debug.server.ready.uriFormat.description%",
103+
"default": "http://localhost:%s"
104+
},
105+
"killOnServerStop": {
106+
"type": "boolean",
107+
"markdownDescription": "%debug.server.ready.killOnServerStop.description%",
108+
"default": false
109+
}
110+
}
111+
},
75112
{
76113
"type": "object",
77114
"additionalProperties": false,

extensions/debug-server-ready/package.nls.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"debug.server.ready.serverReadyAction.description": "Act upon a URI when a server program under debugging is ready (indicated by sending output of the form 'listening on port 3000' or 'Now listening on: https://localhost:5001' to the debug console.)",
66
"debug.server.ready.action.description": "What to do with the URI when the server is ready.",
77
"debug.server.ready.action.openExternally.description": "Open URI externally with the default application.",
8+
"debug.server.ready.action.openInViewer.description": "Open URI in the Viewer pane.",
89
"debug.server.ready.action.debugWithChrome.description": "Start debugging with the 'Debugger for Chrome'.",
910
"debug.server.ready.action.startDebugging.description": "Run another launch configuration.",
1011
"debug.server.ready.pattern.description": "Server is ready if this pattern appears on the debug console. The first capture group must include a URI or a port number.",

extensions/debug-server-ready/src/extension.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
import * as vscode from 'vscode';
77
import * as util from 'util';
88
import { randomUUID } from 'crypto';
9+
// --- Start Positron ---
10+
import * as positron from 'positron';
11+
// --- End Positron ---
912

1013
const PATTERN = 'listening on.* (https?://\\S+|[0-9]+)'; // matches "listening on port 3000" or "Now listening on: https://localhost:5001"
1114
const URI_PORT_FORMAT = 'http://localhost:%s';
@@ -14,7 +17,10 @@ const WEB_ROOT = '${workspaceFolder}';
1417

1518
interface ServerReadyAction {
1619
pattern: string;
17-
action?: 'openExternally' | 'debugWithChrome' | 'debugWithEdge' | 'startDebugging';
20+
// --- Start Positron ---
21+
// Add an action to open the URI in the Viewer pane.
22+
action?: 'openExternally' | 'openInViewer' | 'debugWithChrome' | 'debugWithEdge' | 'startDebugging';
23+
// --- End Positron ---
1824
uriFormat?: string;
1925
webRoot?: string;
2026
name?: string;
@@ -201,6 +207,12 @@ class ServerReadyDetector extends vscode.Disposable {
201207
await this.startDebugSession(session, args.name || 'unspecified');
202208
}
203209
break;
210+
// --- Start Positron ---
211+
// Open the URI in the Viewer pane.
212+
case 'openInViewer':
213+
positron.window.previewUrl(vscode.Uri.parse(uri));
214+
break;
215+
// --- End Positron ---
204216

205217
default:
206218
// not supported

extensions/debug-server-ready/tsconfig.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,8 @@
1111
"src/**/*",
1212
"../../src/vscode-dts/vscode.d.ts",
1313
"../../src/vscode-dts/vscode.proposed.terminalDataWriteEvent.d.ts",
14+
// --- Start Positron ---
15+
"../../src/positron-dts/positron.d.ts",
16+
// --- End Positron ---
1417
]
1518
}

0 commit comments

Comments
 (0)