Skip to content
This repository has been archived by the owner on Feb 1, 2022. It is now read-only.

Commit

Permalink
fix: Breakpoints & scripts work when not paused
Browse files Browse the repository at this point in the history
  • Loading branch information
Jan Krems committed Oct 20, 2016
1 parent 1223b3b commit 6f9883d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions lib/internal/inspect-repl.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ function createRepl(inspector) {
}

function isCurrentScript(script) {
return getCurrentLocation().scriptId === script.scriptId;
return selectedFrame && getCurrentLocation().scriptId === script.scriptId;
}

function formatScripts(displayNatives = false) {
Expand Down Expand Up @@ -354,6 +354,12 @@ function createRepl(inspector) {
}
}

function getSourceSnippet(location, delta = 5) {
const { scriptId } = location;
return Debugger.getScriptSource({ scriptId })
.then(({ scriptSource }) => new SourceSnippet(location, delta, scriptSource));
}

class CallFrame {
constructor(callFrame) {
Object.assign(this, callFrame);
Expand All @@ -374,9 +380,7 @@ function createRepl(inspector) {
}

list(delta = 5) {
const { scriptId } = this.location;
return Debugger.getScriptSource({ scriptId })
.then(({ scriptSource }) => new SourceSnippet(this.location, delta, scriptSource));
return getSourceSnippet(this.location, delta);
}
}

Expand Down Expand Up @@ -557,7 +561,7 @@ function createRepl(inspector) {
function registerBreakpoint({ breakpointId, actualLocation }) {
handleBreakpointResolved({ breakpointId, location: actualLocation });
if (actualLocation && actualLocation.scriptId) {
if (!silent) return list(5);
if (!silent) return getSourceSnippet(actualLocation, 5);
} else {
print(`Warning: script '${script}' was not loaded yet.`);
}
Expand Down

0 comments on commit 6f9883d

Please sign in to comment.