excerpt(): string
The source around a breakpoint, numbered, with a mark on the line the page stopped on.
3 │ export function inspectMe(): number { 4 │ const answer = 42; > 5 │ debugger; 6 │ 7 │ return answer;
Both edges are found rather than counted to. Going up it stops at the line that OPENS the block
the breakpoint is in — the function signature, most of the time — because a window that starts
mid-statement tells you less than one that starts where the scope does. Going down it stops at
the return, since what a function answers is the other half of what you are looking at, and
anything past it belongs to a different frame.
Where neither is within reach the limits win, and a return too far away is not shown at all:
one line below is enough to see where you are, and four lines of unrelated body is noise.
import { excerpt } from './excerpt.ts'; const plain = { painter: () => (text: string) => text }; excerpt('const a = 1;\ndebugger;\n', 2, plain); // ' 1 │ const a = 1;\n> 2 │ debugger;' excerpt('', 1, plain); // '' — nothing to show is shown as nothing