Skip to content

Commit d816d6a

Browse files
authored
Merge pull request #1295 from microsoft/feat/151410
feat: simplify pretty print to align with devtools
2 parents 1a57656 + 3eeb048 commit d816d6a

16 files changed

+101
-269
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
44

55
## Nightly (only)
66

7+
- feat: simplify pretty print to align with devtools ([vscode#151410](https://github.com/microsoft/vscode/issues/151410))
78
- fix: debugged child processes in ext host causing teardown ([#1289](https://github.com/microsoft/vscode-js-debug/issues/1289))
89
- fix: errors thrown in process tree lookup not being visible ([vscode#150754](https://github.com/microsoft/vscode/issues/150754))
910
- chore: adopt new restartFrame semantics from Chrome 104 ([#1283](https://github.com/microsoft/vscode-js-debug/issues/1283))

src/adapter/debugAdapter.ts

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,6 @@ export class DebugAdapter implements IDisposable {
102102
this.dap.on('enableCustomBreakpoints', params => this.enableCustomBreakpoints(params));
103103
this.dap.on('toggleSkipFileStatus', params => this._toggleSkipFileStatus(params));
104104
this.dap.on('disableCustomBreakpoints', params => this._disableCustomBreakpoints(params));
105-
this.dap.on('canPrettyPrintSource', params => this._canPrettyPrintSource(params));
106105
this.dap.on('prettyPrintSource', params => this._prettyPrintSource(params));
107106
this.dap.on('revealPage', () => this._withThread(thread => thread.revealPage()));
108107
this.dap.on('getPerformance', () =>
@@ -438,20 +437,6 @@ export class DebugAdapter implements IDisposable {
438437
return {};
439438
}
440439

441-
async _canPrettyPrintSource(
442-
params: Dap.CanPrettyPrintSourceParams,
443-
): Promise<Dap.CanPrettyPrintSourceResult | Dap.Error> {
444-
if (!params.source) {
445-
return { canPrettyPrint: false };
446-
}
447-
448-
params.source.path = urlUtils.platformPathToPreferredCase(params.source.path);
449-
const source = this.sourceContainer.source(params.source);
450-
if (!source)
451-
return errors.createSilentError(localize('error.sourceNotFound', 'Source not found'));
452-
return { canPrettyPrint: source.canPrettyPrint() };
453-
}
454-
455440
async _prettyPrintSource(
456441
params: Dap.PrettyPrintSourceParams,
457442
): Promise<Dap.PrettyPrintSourceResult | Dap.Error> {

src/adapter/sources.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -223,20 +223,13 @@ export class Source {
223223
return 'text/javascript';
224224
}
225225

226-
/**
227-
* Gets whether this source is able to be pretty-printed.
228-
*/
229-
public canPrettyPrint(): boolean {
230-
return this._container && !this._name.endsWith('-pretty.js');
231-
}
232-
233226
/**
234227
* Pretty-prints the source. Generates a beauitified source map if possible
235228
* and it hasn't already been done, and returns the created map and created
236229
* ephemeral source. Returns undefined if the source can't be beautified.
237230
*/
238231
public async prettyPrint(): Promise<{ map: SourceMap; source: Source } | undefined> {
239-
if (!this._container || !this.canPrettyPrint()) {
232+
if (!this._container) {
240233
return undefined;
241234
}
242235

src/build/dapCustom.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -107,29 +107,6 @@ const dapCustom: JSONSchema4 = {
107107
required: ['ids'],
108108
}),
109109

110-
...makeRequest(
111-
'canPrettyPrintSource',
112-
'Returns whether particular source can be pretty-printed.',
113-
{
114-
properties: {
115-
source: {
116-
$ref: '#/definitions/Source',
117-
description: 'Source to be pretty printed.',
118-
},
119-
},
120-
required: ['source'],
121-
},
122-
{
123-
required: ['canPrettyPrint'],
124-
properties: {
125-
canPrettyPrint: {
126-
type: 'boolean',
127-
description: 'Whether source can be pretty printed.',
128-
},
129-
},
130-
},
131-
),
132-
133110
...makeRequest('prettyPrintSource', 'Pretty prints source for debugging.', {
134111
properties: {
135112
source: {

src/build/generate-contributions.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
AutoAttachMode,
99
Commands,
1010
Configuration,
11+
ContextKey,
1112
Contributions,
1213
CustomViews,
1314
DebugType,
@@ -1110,11 +1111,6 @@ const configurationSchema: ConfigurationAttributes<IConfigurationTypes> = {
11101111
default: {},
11111112
properties: nodeTerminalConfiguration.configurationAttributes as { [key: string]: JSONSchema6 },
11121113
},
1113-
[Configuration.SuggestPrettyPrinting]: {
1114-
type: 'boolean',
1115-
description: refString('configuration.suggestPrettyPrinting'),
1116-
default: true,
1117-
},
11181114
[Configuration.AutoServerTunnelOpen]: {
11191115
type: 'boolean',
11201116
description: refString('configuration.automaticallyTunnelRemoteServer'),
@@ -1209,6 +1205,7 @@ const commands: ReadonlyArray<{
12091205
command: Commands.PrettyPrint,
12101206
title: refString('pretty.print.script'),
12111207
category: 'Debug',
1208+
icon: '$(json)',
12121209
},
12131210
{
12141211
command: Commands.ToggleSkipping,
@@ -1452,6 +1449,13 @@ const menus: Menus = {
14521449
when: `view == ${CustomViews.ExcludedCallers}`,
14531450
},
14541451
],
1452+
'editor/title': [
1453+
{
1454+
command: Commands.PrettyPrint,
1455+
group: 'navigation',
1456+
when: `resource in ${ContextKey.CanPrettyPrint}`,
1457+
},
1458+
],
14551459
};
14561460

14571461
const keybindings = [

src/build/strings.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,8 +280,6 @@ const strings = {
280280
'Where a "Run" and "Debug" code lens should be shown in your npm scripts. It may be on "all", scripts, on "top" of the script section, or "never".',
281281
'configuration.terminalOptions':
282282
'Default launch options for the JavaScript debug terminal and npm scripts.',
283-
'configuration.suggestPrettyPrinting':
284-
'Whether to suggest pretty printing JavaScript code that looks minified when you step into it.',
285283
'configuration.automaticallyTunnelRemoteServer':
286284
'When debugging a remote web app, configures whether to automatically tunnel the remote server to your local machine.',
287285
'configuration.debugByLinkOptions':

src/common/contributionUtils.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ export const enum Configuration {
134134
TerminalDebugConfig = 'debug.javascript.terminalOptions',
135135
PickAndAttachDebugOptions = 'debug.javascript.pickAndAttachOptions',
136136
DebugByLinkOptions = 'debug.javascript.debugByLinkOptions',
137-
SuggestPrettyPrinting = 'debug.javascript.suggestPrettyPrinting',
138137
AutoServerTunnelOpen = 'debug.javascript.automaticallyTunnelRemoteServer',
139138
AutoAttachMode = 'debug.javascript.autoAttachFilter',
140139
AutoAttachSmartPatterns = 'debug.javascript.autoAttachSmartPattern',
@@ -153,7 +152,6 @@ export interface IConfigurationTypes {
153152
[Configuration.NpmScriptLens]: 'all' | 'top' | 'never';
154153
[Configuration.TerminalDebugConfig]: Partial<ITerminalLaunchConfiguration>;
155154
[Configuration.PickAndAttachDebugOptions]: Partial<INodeAttachConfiguration>;
156-
[Configuration.SuggestPrettyPrinting]: boolean;
157155
[Configuration.AutoServerTunnelOpen]: boolean;
158156
[Configuration.DebugByLinkOptions]:
159157
| DebugByLinkState
@@ -256,3 +254,21 @@ export const writeConfig = <K extends keyof IConfigurationTypes>(
256254
value: IConfigurationTypes[K],
257255
target?: ConfigurationTarget,
258256
) => wsp.getConfiguration().update(key, value, target);
257+
258+
export const enum ContextKey {
259+
HasExcludedCallers = 'jsDebugHasExcludedCallers',
260+
CanPrettyPrint = 'jsDebugCanPrettyPrint',
261+
IsProfiling = 'jsDebugIsProfiling',
262+
}
263+
264+
export interface IContextKeyTypes {
265+
[ContextKey.HasExcludedCallers]: boolean;
266+
[ContextKey.CanPrettyPrint]: string[];
267+
[ContextKey.IsProfiling]: boolean;
268+
}
269+
270+
export const setContextKey = async <K extends keyof IContextKeyTypes>(
271+
ns: typeof commands,
272+
key: K,
273+
value: IContextKeyTypes[K] | null,
274+
) => await ns.executeCommand('setContext', key, value);

src/dap/api.d.ts

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -842,20 +842,6 @@ export namespace Dap {
842842
params: DisableCustomBreakpointsParams,
843843
): Promise<DisableCustomBreakpointsResult>;
844844

845-
/**
846-
* Returns whether particular source can be pretty-printed.
847-
*/
848-
on(
849-
request: 'canPrettyPrintSource',
850-
handler: (params: CanPrettyPrintSourceParams) => Promise<CanPrettyPrintSourceResult | Error>,
851-
): () => void;
852-
/**
853-
* Returns whether particular source can be pretty-printed.
854-
*/
855-
canPrettyPrintSourceRequest(
856-
params: CanPrettyPrintSourceParams,
857-
): Promise<CanPrettyPrintSourceResult>;
858-
859845
/**
860846
* Pretty prints source for debugging.
861847
*/
@@ -1601,11 +1587,6 @@ export namespace Dap {
16011587
params: DisableCustomBreakpointsParams,
16021588
): Promise<DisableCustomBreakpointsResult>;
16031589

1604-
/**
1605-
* Returns whether particular source can be pretty-printed.
1606-
*/
1607-
canPrettyPrintSource(params: CanPrettyPrintSourceParams): Promise<CanPrettyPrintSourceResult>;
1608-
16091590
/**
16101591
* Pretty prints source for debugging.
16111592
*/
@@ -1881,20 +1862,6 @@ export namespace Dap {
18811862
breakpoints: BreakpointLocation[];
18821863
}
18831864

1884-
export interface CanPrettyPrintSourceParams {
1885-
/**
1886-
* Source to be pretty printed.
1887-
*/
1888-
source: Source;
1889-
}
1890-
1891-
export interface CanPrettyPrintSourceResult {
1892-
/**
1893-
* Whether source can be pretty printed.
1894-
*/
1895-
canPrettyPrint: boolean;
1896-
}
1897-
18981865
export interface CancelParams {
18991866
/**
19001867
* The ID (attribute 'seq') of the request to cancel. If missing no request is cancelled.

src/dap/telemetryClassification.d.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@ interface IDAPOperationClassification {
9696
'!enablecustombreakpoints.errors': { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth' };
9797
disablecustombreakpoints: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth' };
9898
'!disablecustombreakpoints.errors': { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth' };
99-
canprettyprintsource: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth' };
100-
'!canprettyprintsource.errors': { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth' };
10199
prettyprintsource: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth' };
102100
'!prettyprintsource.errors': { classification: 'CallstackOrException'; purpose: 'PerformanceAndHealth' };
103101
toggleskipfilestatus: { classification: 'SystemMetaData'; purpose: 'PerformanceAndHealth' };

src/extension.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import { registerCustomBreakpointsUI } from './ui/customBreakpointsUI';
2222
import { debugNpmScript } from './ui/debugNpmScript';
2323
import { DebugSessionTracker } from './ui/debugSessionTracker';
2424
import { registerDebugTerminalUI } from './ui/debugTerminalUI';
25-
import { PrettyPrintTrackerFactory } from './ui/prettyPrint';
2625
import { attachProcess, pickProcess } from './ui/processPicker';
2726
import { registerProfilingCommand } from './ui/profiling';
2827
import { registerRequestCDPProxy } from './ui/requestCDPProxy';
@@ -87,7 +86,6 @@ export function activate(context: vscode.ExtensionContext) {
8786
const debugSessionTracker = services.get(DebugSessionTracker);
8887
debugSessionTracker.attach();
8988

90-
context.subscriptions.push(PrettyPrintTrackerFactory.register(debugSessionTracker));
9189
registerCompanionBrowserLaunch(context);
9290
registerCustomBreakpointsUI(context, debugSessionTracker);
9391
registerDebugTerminalUI(

0 commit comments

Comments
 (0)