This repository has been archived by the owner on Oct 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 119
Fix break-on-load breakpoint not hitting on the first line for Chrome #285
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,7 +88,7 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { | |
protected _domains = new Map<CrdpDomain, Crdp.Schema.Domain>(); | ||
private _clientAttached: boolean; | ||
private _currentPauseNotification: Crdp.Debugger.PausedEvent; | ||
private _committedBreakpointsByUrl: Map<string, Crdp.Debugger.BreakpointId[]>; | ||
private _committedBreakpointsByUrl: Map<string, ISetBreakpointResult[]>; | ||
private _exception: Crdp.Runtime.RemoteObject; | ||
private _setBreakpointsRequestQ: Promise<any>; | ||
private _expectingResumedEvent: boolean; | ||
|
@@ -175,6 +175,10 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { | |
return this._pendingBreakpointsByUrl; | ||
} | ||
|
||
public get committedBreakpointsByUrl(): Map<string, ISetBreakpointResult[]> { | ||
return this._committedBreakpointsByUrl; | ||
} | ||
|
||
public get sourceMapTransformer(): BaseSourceMapTransformer{ | ||
return this._sourceMapTransformer; | ||
} | ||
|
@@ -188,7 +192,7 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { | |
this._scriptsById = new Map<Crdp.Runtime.ScriptId, Crdp.Debugger.ScriptParsedEvent>(); | ||
this._scriptsByUrl = new Map<string, Crdp.Debugger.ScriptParsedEvent>(); | ||
|
||
this._committedBreakpointsByUrl = new Map<string, Crdp.Debugger.BreakpointId[]>(); | ||
this._committedBreakpointsByUrl = new Map<string, ISetBreakpointResult[]>(); | ||
this._setBreakpointsRequestQ = Promise.resolve(); | ||
|
||
this._pathTransformer.clearTargetContext(); | ||
|
@@ -923,10 +927,6 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { | |
return this.setBreakpoints(pendingBP.args, pendingBP.requestSeq, pendingBP.ids).then(response => { | ||
response.breakpoints.forEach((bp, i) => { | ||
bp.id = pendingBP.ids[i]; | ||
// If any of the unbound breakpoints in this file is on (1,1), we set userBreakpointOnLine1Col1 to true | ||
if (bp.line === 1 && bp.column === 1 && this.breakOnLoadActive) { | ||
this._breakOnLoadHelper.userBreakpointOnLine1Col1 = true; | ||
} | ||
this._session.sendEvent(new BreakpointEvent('changed', bp)); | ||
}); | ||
}); | ||
|
@@ -945,8 +945,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { | |
} | ||
|
||
const committedBps = this._committedBreakpointsByUrl.get(script.url) || []; | ||
if (committedBps.indexOf(params.breakpointId) === -1) { | ||
committedBps.push(params.breakpointId); | ||
if (committedBps.findIndex(committedBp => committedBp.breakpointId === params.breakpointId) === -1) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I prefer There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. changed |
||
committedBps.push({breakpointId: params.breakpointId, actualLocation: params.location}); | ||
} | ||
this._committedBreakpointsByUrl.set(script.url, committedBps); | ||
|
||
|
@@ -1233,8 +1233,8 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { | |
// but there is a chrome bug where when removing 5+ or so breakpoints at once, it gets into a weird | ||
// state where later adds on the same line will fail with 'breakpoint already exists' even though it | ||
// does not break there. | ||
return this._committedBreakpointsByUrl.get(url).reduce((p, breakpointId) => { | ||
return p.then(() => this.chrome.Debugger.removeBreakpoint({ breakpointId })).then(() => { }); | ||
return this._committedBreakpointsByUrl.get(url).reduce((p, bp) => { | ||
return p.then(() => this.chrome.Debugger.removeBreakpoint({ breakpointId: bp.breakpointId })).then(() => { }); | ||
}, Promise.resolve()).then(() => { | ||
this._committedBreakpointsByUrl.delete(url); | ||
}); | ||
|
@@ -1318,12 +1318,11 @@ export abstract class ChromeDebugAdapter implements IDebugAdapter { | |
|
||
private targetBreakpointResponsesToClientBreakpoints(url: string, responses: ISetBreakpointResult[], requestBps: DebugProtocol.SourceBreakpoint[], ids?: number[]): DebugProtocol.Breakpoint[] { | ||
// Don't cache errored responses | ||
const committedBpIds = responses | ||
.filter(response => response && response.breakpointId) | ||
.map(response => response.breakpointId); | ||
const committedBps = responses | ||
.filter(response => response && response.breakpointId); | ||
|
||
// Cache successfully set breakpoint ids from chrome in committedBreakpoints set | ||
this._committedBreakpointsByUrl.set(url, committedBpIds); | ||
this._committedBreakpointsByUrl.set(url, committedBps); | ||
|
||
// Map committed breakpoints to DebugProtocol response breakpoints | ||
return responses | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why just a "paused" script?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are right. Renaming to getScriptUrlFromId