diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index dea27d0f8d0..31ab5d2adec 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -39,7 +39,10 @@ namespace ts.BreakpointResolver { return spanInNode(tokenAtLocation); function textSpan(startNode: Node, endNode?: Node) { - return createTextSpanFromBounds(startNode.getStart(sourceFile), (endNode || startNode).getEnd()); + const start = startNode.decorators ? + skipTrivia(sourceFile.text, startNode.decorators.end) : + startNode.getStart(sourceFile); + return createTextSpanFromBounds(start, (endNode || startNode).getEnd()); } function spanInNodeIfStartsOnSameLine(node: Node, otherwiseOnNode?: Node): TextSpan { diff --git a/tests/baselines/reference/bpSpan_decorators.baseline b/tests/baselines/reference/bpSpan_decorators.baseline index bba31d1df40..179cdb08906 100644 --- a/tests/baselines/reference/bpSpan_decorators.baseline +++ b/tests/baselines/reference/bpSpan_decorators.baseline @@ -29,9 +29,7 @@ -------------------------------- 8 >@ClassDecorator1 - ~ => Pos: (594 to 594) SpanInfo: {"start":594,"length":952} - >@ClassDecorator1 - >@ClassDecorator2(10) + ~ => Pos: (594 to 594) SpanInfo: {"start":632,"length":914} >class Greeter { > constructor( > @ParameterDecorator1 @@ -77,7 +75,7 @@ > this.greeting = greetings; > } >} - >:=> (line 8, col 0) to (line 54, col 1) + >:=> (line 10, col 0) to (line 54, col 1) 8 >@ClassDecorator1 ~~~~~~~~~~~~~~~~ => Pos: (595 to 610) SpanInfo: {"start":595,"length":36} @@ -94,9 +92,7 @@ -------------------------------- 10 >class Greeter { - ~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":594,"length":952} - >@ClassDecorator1 - >@ClassDecorator2(10) + ~~~~~~~~~~~~~~~~ => Pos: (632 to 647) SpanInfo: {"start":632,"length":914} >class Greeter { > constructor( > @ParameterDecorator1 @@ -142,7 +138,7 @@ > this.greeting = greetings; > } >} - >:=> (line 8, col 0) to (line 54, col 1) + >:=> (line 10, col 0) to (line 54, col 1) -------------------------------- 11 > constructor( @@ -152,11 +148,9 @@ -------------------------------- 12 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":673,"length":85} - >@ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string - >:=> (line 12, col 8) to (line 14, col 31) + ~~~~~~~~~ => Pos: (665 to 673) SpanInfo: {"start":735,"length":23} + >public greeting: string + >:=> (line 14, col 8) to (line 14, col 31) 12 > @ParameterDecorator1 ~~~~~~~~~~~~~~~~~~~~ => Pos: (674 to 693) SpanInfo: {"start":674,"length":52} @@ -173,11 +167,9 @@ -------------------------------- 14 > public greeting: string, - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":673,"length":85} - >@ParameterDecorator1 - > @ParameterDecorator2(20) - > public greeting: string - >:=> (line 12, col 8) to (line 14, col 31) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (727 to 759) SpanInfo: {"start":735,"length":23} + >public greeting: string + >:=> (line 14, col 8) to (line 14, col 31) -------------------------------- 15 > @@ -185,11 +177,9 @@ -------------------------------- 16 > @ParameterDecorator1 - ~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":769,"length":80} - >@ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] - >:=> (line 16, col 8) to (line 18, col 26) + ~~~~~~~~~ => Pos: (761 to 769) SpanInfo: {"start":835,"length":14} + >...b: string[] + >:=> (line 18, col 12) to (line 18, col 26) 16 > @ParameterDecorator1 ~~~~~~~~~~~~~~~~~~~~ => Pos: (770 to 789) SpanInfo: {"start":770,"length":52} @@ -206,11 +196,9 @@ -------------------------------- 18 > ...b: string[]) { - ~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":769,"length":80} - >@ParameterDecorator1 - > @ParameterDecorator2(30) - > ...b: string[] - >:=> (line 16, col 8) to (line 18, col 26) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (823 to 849) SpanInfo: {"start":835,"length":14} + >...b: string[] + >:=> (line 18, col 12) to (line 18, col 26) 18 > ...b: string[]) { ~~~ => Pos: (850 to 852) SpanInfo: {"start":857,"length":1} @@ -229,13 +217,11 @@ -------------------------------- 21 > @PropertyDecorator1 - ~~~~~ => Pos: (860 to 864) SpanInfo: {"start":864,"length":116} - >@PropertyDecorator1 - > @PropertyDecorator2(40) - > greet() { + ~~~~~ => Pos: (860 to 864) SpanInfo: {"start":916,"length":64} + >greet() { > return "