diff --git a/src/services/breakpoints.ts b/src/services/breakpoints.ts index 386970cac5a..94fbcb785e8 100644 --- a/src/services/breakpoints.ts +++ b/src/services/breakpoints.ts @@ -245,6 +245,9 @@ namespace ts.BreakpointResolver { case SyntaxKind.CloseBraceToken: return spanInCloseBraceToken(node); + + case SyntaxKind.CloseBracketToken: + return spanInCloseBracketToken(node); case SyntaxKind.OpenParenToken: return spanInOpenParenToken(node); @@ -512,6 +515,19 @@ namespace ts.BreakpointResolver { } } + function spanInCloseBracketToken(node: Node): TextSpan { + switch (node.parent.kind) { + case SyntaxKind.ArrayBindingPattern: + // Breakpoint in last binding element or binding pattern if it contains no elements + let bindingPattern = node.parent; + return spanInNode(lastOrUndefined(bindingPattern.elements) || bindingPattern); + + // Default to parent node + default: + return spanInNode(node.parent); + } + } + function spanInOpenParenToken(node: Node): TextSpan { if (node.parent.kind === SyntaxKind.DoStatement) { // Go to while keyword and do action instead diff --git a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern.baseline b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern.baseline index 0263cafa0a6..0639ca49c9d 100644 --- a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern.baseline +++ b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern.baseline @@ -51,14 +51,9 @@ >:=> (line 9, col 15) to (line 9, col 21) 9 >let [numberA2, nameA2, skillA2] = robotA; - ~~~~~~~~ => Pos: (254 to 261) SpanInfo: {"start":255,"length":7} + ~~~~~~~~~~~~~~~~~~~~ => Pos: (254 to 273) SpanInfo: {"start":255,"length":7} >skillA2 >:=> (line 9, col 23) to (line 9, col 30) -9 >let [numberA2, nameA2, skillA2] = robotA; - - ~~~~~~~~~~~~ => Pos: (262 to 273) SpanInfo: {"start":237,"length":8} - >numberA2 - >:=> (line 9, col 5) to (line 9, col 13) -------------------------------- 10 >let [numberC2] = [3, "edging", "Trimming edges"]; @@ -78,24 +73,15 @@ >:=> (line 11, col 14) to (line 11, col 19) 11 >let [numberC, nameC, skillC] = [3, "edging", "Trimming edges"]; - ~~~~~~~ => Pos: (344 to 350) SpanInfo: {"start":345,"length":6} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (344 to 387) SpanInfo: {"start":345,"length":6} >skillC >:=> (line 11, col 21) to (line 11, col 27) -11 >let [numberC, nameC, skillC] = [3, "edging", "Trimming edges"]; - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (351 to 387) SpanInfo: {"start":329,"length":7} - >numberC - >:=> (line 11, col 5) to (line 11, col 12) -------------------------------- 12 >let [numberA3, ...robotAInfo] = robotA; ~~~~~~~~~~~~~~ => Pos: (388 to 401) SpanInfo: {"start":393,"length":8} >numberA3 >:=> (line 12, col 5) to (line 12, col 13) 12 >let [numberA3, ...robotAInfo] = robotA; - ~~~~~~~~~~~~~~ => Pos: (402 to 415) SpanInfo: {"start":403,"length":13} + ~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (402 to 426) SpanInfo: {"start":403,"length":13} >...robotAInfo - >:=> (line 12, col 15) to (line 12, col 28) -12 >let [numberA3, ...robotAInfo] = robotA; - ~~~~~~~~~~~ => Pos: (416 to 426) SpanInfo: {"start":393,"length":8} - >numberA3 - >:=> (line 12, col 5) to (line 12, col 13) \ No newline at end of file + >:=> (line 12, col 15) to (line 12, col 28) \ No newline at end of file diff --git a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern2.baseline b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern2.baseline index 8b80f6420df..cb980a37c74 100644 --- a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern2.baseline +++ b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPattern2.baseline @@ -55,19 +55,14 @@ >:=> (line 10, col 14) to (line 10, col 27) 10 >let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA; - ~~~~~~~~~~~~~~~~ => Pos: (331 to 346) SpanInfo: {"start":332,"length":15} + ~~~~~~~~~~~~~~~~~ => Pos: (331 to 347) SpanInfo: {"start":332,"length":15} >secondarySkillA >:=> (line 10, col 29) to (line 10, col 44) 10 >let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA; - ~ => Pos: (347 to 347) SpanInfo: {"start":317,"length":13} - >primarySkillA - >:=> (line 10, col 14) to (line 10, col 27) -10 >let [nameMA, [primarySkillA, secondarySkillA]] = multiRobotA; - - ~~~~~~~~~~~~~~~~~=> Pos: (348 to 364) SpanInfo: {"start":308,"length":6} - >nameMA - >:=> (line 10, col 5) to (line 10, col 11) + ~~~~~~~~~~~~~~~~~=> Pos: (348 to 364) SpanInfo: {"start":316,"length":32} + >[primarySkillA, secondarySkillA] + >:=> (line 10, col 13) to (line 10, col 45) -------------------------------- 11 > @@ -91,19 +86,14 @@ >:=> (line 13, col 15) to (line 13, col 28) 13 >let [nameMC2, [primarySkillC, secondarySkillC]] = ["roomba", ["vaccum", "mopping"]]; - ~~~~~~~~~~~~~~~~ => Pos: (445 to 460) SpanInfo: {"start":446,"length":15} + ~~~~~~~~~~~~~~~~~=> Pos: (445 to 461) SpanInfo: {"start":446,"length":15} >secondarySkillC >:=> (line 13, col 30) to (line 13, col 45) 13 >let [nameMC2, [primarySkillC, secondarySkillC]] = ["roomba", ["vaccum", "mopping"]]; - ~=> Pos: (461 to 461) SpanInfo: {"start":431,"length":13} - >primarySkillC - >:=> (line 13, col 15) to (line 13, col 28) -13 >let [nameMC2, [primarySkillC, secondarySkillC]] = ["roomba", ["vaccum", "mopping"]]; - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (462 to 500) SpanInfo: {"start":421,"length":7} - >nameMC2 - >:=> (line 13, col 5) to (line 13, col 12) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (462 to 500) SpanInfo: {"start":430,"length":32} + >[primarySkillC, secondarySkillC] + >:=> (line 13, col 14) to (line 13, col 46) -------------------------------- 14 > diff --git a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues.baseline b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues.baseline index 9f025f3646a..e3b43164563 100644 --- a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues.baseline +++ b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues.baseline @@ -51,14 +51,9 @@ >:=> (line 9, col 20) to (line 9, col 37) 9 >let [numberA2 = -1, nameA2 = "noName", skillA2 = "noSkill"] = robotA; - ~~~~~~~~~~~~~~~~~~~~=> Pos: (286 to 305) SpanInfo: {"start":287,"length":19} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (286 to 317) SpanInfo: {"start":287,"length":19} >skillA2 = "noSkill" >:=> (line 9, col 39) to (line 9, col 58) -9 >let [numberA2 = -1, nameA2 = "noName", skillA2 = "noSkill"] = robotA; - - ~~~~~~~~~~~~=> Pos: (306 to 317) SpanInfo: {"start":253,"length":13} - >numberA2 = -1 - >:=> (line 9, col 5) to (line 9, col 18) -------------------------------- 10 >let [numberC2 = -1] = [3, "edging", "Trimming edges"]; @@ -78,24 +73,15 @@ >:=> (line 11, col 19) to (line 11, col 35) 11 >let [numberC = -1, nameC = "noName", skillC = "noSkill"] = [3, "edging", "Trimming edges"]; - ~~~~~~~~~~~~~~~~~~~=> Pos: (409 to 427) SpanInfo: {"start":410,"length":18} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (409 to 464) SpanInfo: {"start":410,"length":18} >skillC = "noSkill" >:=> (line 11, col 37) to (line 11, col 55) -11 >let [numberC = -1, nameC = "noName", skillC = "noSkill"] = [3, "edging", "Trimming edges"]; - - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (428 to 464) SpanInfo: {"start":378,"length":12} - >numberC = -1 - >:=> (line 11, col 5) to (line 11, col 17) -------------------------------- 12 >let [numberA3 = -1, ...robotAInfo] = robotA; ~~~~~~~~~~~~~~~~~~~ => Pos: (465 to 483) SpanInfo: {"start":470,"length":13} >numberA3 = -1 >:=> (line 12, col 5) to (line 12, col 18) 12 >let [numberA3 = -1, ...robotAInfo] = robotA; - ~~~~~~~~~~~~~~ => Pos: (484 to 497) SpanInfo: {"start":485,"length":13} + ~~~~~~~~~~~~~~~~~~~~~~~~~ => Pos: (484 to 508) SpanInfo: {"start":485,"length":13} >...robotAInfo - >:=> (line 12, col 20) to (line 12, col 33) -12 >let [numberA3 = -1, ...robotAInfo] = robotA; - ~~~~~~~~~~~ => Pos: (498 to 508) SpanInfo: {"start":470,"length":13} - >numberA3 = -1 - >:=> (line 12, col 5) to (line 12, col 18) \ No newline at end of file + >:=> (line 12, col 20) to (line 12, col 33) \ No newline at end of file diff --git a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues2.baseline b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues2.baseline index 7a1667015fd..ddbfdd29268 100644 --- a/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues2.baseline +++ b/tests/baselines/reference/bpSpanDestructuringVariableStatementArrayBindingPatternDefaultValues2.baseline @@ -51,24 +51,14 @@ >:=> (line 9, col 25) to (line 9, col 50) 9 >let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (382 to 409) SpanInfo: {"start":383,"length":27} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (382 to 410) SpanInfo: {"start":383,"length":27} >secondarySkillA = "noSkill" >:=> (line 9, col 52) to (line 9, col 79) 9 >let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; - ~=> Pos: (410 to 410) SpanInfo: {"start":356,"length":25} - >primarySkillA = "noSkill" - >:=> (line 9, col 25) to (line 9, col 50) -9 >let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; - - ~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (411 to 435) SpanInfo: {"start":355,"length":81} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (411 to 452) SpanInfo: {"start":355,"length":81} >[primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"] >:=> (line 9, col 24) to (line 9, col 105) -9 >let [nameMA = "noName", [primarySkillA = "noSkill", secondarySkillA = "noSkill"] = ["noSkill", "noSkill"]] = multiRobotA; - - ~~~~~~~~~~~~~~~~~=> Pos: (436 to 452) SpanInfo: {"start":336,"length":17} - >nameMA = "noName" - >:=> (line 9, col 5) to (line 9, col 22) -------------------------------- 10 >let [nameMC = "noName" ] = ["roomba", ["vaccum", "mopping"]]; @@ -85,18 +75,10 @@ >primarySkillC = "noSkill" >:=> (line 11, col 26) to (line 11, col 51) 11 >let [nameMC2 = "noName", [primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vaccum", "mopping"]]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (567 to 594) SpanInfo: {"start":568,"length":27} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (567 to 595) SpanInfo: {"start":568,"length":27} >secondarySkillC = "noSkill" >:=> (line 11, col 53) to (line 11, col 80) 11 >let [nameMC2 = "noName", [primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vaccum", "mopping"]]; - ~=> Pos: (595 to 595) SpanInfo: {"start":541,"length":25} - >primarySkillC = "noSkill" - >:=> (line 11, col 26) to (line 11, col 51) -11 >let [nameMC2 = "noName", [primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vaccum", "mopping"]]; - ~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (596 to 620) SpanInfo: {"start":540,"length":81} + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (596 to 658) SpanInfo: {"start":540,"length":81} >[primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"] - >:=> (line 11, col 25) to (line 11, col 106) -11 >let [nameMC2 = "noName", [primarySkillC = "noSkill", secondarySkillC = "noSkill"] = ["noSkill", "noSkill"]] = ["roomba", ["vaccum", "mopping"]]; - ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~=> Pos: (621 to 658) SpanInfo: {"start":520,"length":18} - >nameMC2 = "noName" - >:=> (line 11, col 5) to (line 11, col 23) \ No newline at end of file + >:=> (line 11, col 25) to (line 11, col 106) \ No newline at end of file