From d2281440bfc3658e3ed325778abae4e8bcc16134 Mon Sep 17 00:00:00 2001 From: Pokey Rule <755842+pokey@users.noreply.github.com> Date: Sun, 28 Jan 2024 18:16:20 +0000 Subject: [PATCH] Don't show lines in our facet tests that are outside of the range (#2207) Fixes https://github.com/cursorless-dev/cursorless/issues/2164 ## Checklist - [-] I have added [tests](https://www.cursorless.org/docs/contributing/test-case-recorder/) - [-] I have updated the [docs](https://github.com/cursorless-dev/cursorless/tree/main/docs) and [cheatsheet](https://github.com/cursorless-dev/cursorless/tree/main/cursorless-talon/src/cheatsheet) - [-] I have not broken the cheatsheet --- .../fixtures/scopes/java/name.foreach.scope | 16 ------- .../fixtures/scopes/java/type.foreach.scope | 16 ------- .../fixtures/scopes/java/value.foreach.scope | 12 ----- .../argument.formal.iteration.scope | 4 -- .../scopes/javascript/argument.formal.scope | 4 -- .../scopes/javascript/branch.if.scope | 46 ------------------- .../scopes/javascript/branch.switchCase.scope | 12 ----- .../scopes/javascript/branch.try.scope | 36 --------------- .../scopes/javascript/className.scope | 16 ------- .../scopes/javascript/condition.doWhile.scope | 4 -- .../scopes/javascript/condition.for.scope | 12 ----- .../scopes/javascript/condition.if.scope | 4 -- .../javascript/condition.switchCase.scope | 16 ------- .../scopes/javascript/condition.while.scope | 4 -- .../scopes/javascript/functionName.scope | 8 ---- .../scopes/javascript/name.class.scope | 16 ------- .../scopes/javascript/name.field.scope | 32 ------------- .../scopes/javascript/name.foreach.scope | 16 ------- .../scopes/javascript/name.function.scope | 8 ---- .../javascript/namedFunction.method.scope | 16 ------- .../statement.iteration.document.scope | 4 -- .../javascript/switchStatementSubject.scope | 4 -- .../scopes/javascript/value.field.scope | 16 ------- .../scopes/javascript/value.foreach.scope | 12 ----- .../scopes/javascript/value.return.scope | 16 ------- .../fixtures/scopes/python/name.foreach.scope | 8 ---- .../scopes/python/value.foreach.scope | 6 --- .../suite/fixtures/scopes/textual/line2.scope | 26 ----------- .../fixtures/scopes/textual/paragraph.scope | 24 ---------- .../scopes/typescript/type.field.scope | 16 ------- .../typescript/type.formalParameter.scope | 16 ------- .../scopes/typescript/type.return.scope | 12 ----- .../src/suite/serializeTargetRange.ts | 28 ++++++----- 33 files changed, 16 insertions(+), 470 deletions(-) diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/name.foreach.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/name.foreach.scope index 61d7ad9369..abfa64910b 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/name.foreach.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/name.foreach.scope @@ -6,34 +6,18 @@ for (final Item item : items) { [Content] = 0:16-0:20 0| for (final Item item : items) { >----< -1| - -2| } - [Removal] = 0:16-0:21 0| for (final Item item : items) { >-----< -1| - -2| } - [Leading delimiter] = 0:15-0:16 0| for (final Item item : items) { >-< -1| - -2| } - [Trailing delimiter] = 0:20-0:21 0| for (final Item item : items) { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| for (final Item item : items) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/type.foreach.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/type.foreach.scope index 7c3c14b568..ee25dc2976 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/type.foreach.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/type.foreach.scope @@ -6,34 +6,18 @@ for (final Item item : items) { [Content] = 0:11-0:15 0| for (final Item item : items) { >----< -1| - -2| } - [Removal] = 0:11-0:16 0| for (final Item item : items) { >-----< -1| - -2| } - [Leading delimiter] = 0:10-0:11 0| for (final Item item : items) { >-< -1| - -2| } - [Trailing delimiter] = 0:15-0:16 0| for (final Item item : items) { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| for (final Item item : items) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/value.foreach.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/value.foreach.scope index f9609888a8..66171bc4a6 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/value.foreach.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/java/value.foreach.scope @@ -6,26 +6,14 @@ for (final Item item : items) { [Content] = 0:23-0:28 0| for (final Item item : items) { >-----< -1| - -2| } - [Removal] = 0:22-0:28 0| for (final Item item : items) { >------< -1| - -2| } - [Leading delimiter] = 0:22-0:23 0| for (final Item item : items) { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| for (final Item item : items) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.iteration.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.iteration.scope index 9e816c530d..5950d2c393 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.iteration.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.iteration.scope @@ -6,10 +6,6 @@ function myFunk(arg1, arg2) { [Range] = 0:16-0:26 0| function myFunk(arg1, arg2) { >----------< -1| - -2| } - [Domain] = 0:0-2:1 0| function myFunk(arg1, arg2) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.scope index dd032ebeac..0b48f4306d 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/argument.formal.scope @@ -8,9 +8,5 @@ function myFunk(value) { [Domain] = 0:16-0:21 0| function myFunk(value) { >-----< -1| - -2| } - [Insertion delimiter] = ", " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.if.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.if.scope index dcfa942f2c..6105b54ad2 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.if.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.if.scope @@ -17,18 +17,6 @@ else { 2| } -< -3| else if (false) { - -4| - -5| } - -6| else { - -7| - -8| } - [#1 Removal] = 0:0-3:5 0| if (true) { @@ -39,16 +27,6 @@ else { - 3| else if (false) { -----< -4| - -5| } - -6| else { - -7| - -8| } - [#1 Insertion delimiter] = "\n" @@ -56,24 +34,12 @@ else { [#2 Content] = [#2 Removal] = [#2 Domain] = 3:0-5:1 -0| if (true) { - -1| - -2| } - 3| else if (false) { >----------------- 4| 5| } -< -6| else { - -7| - -8| } - [#2 Insertion delimiter] = "\n" @@ -81,18 +47,6 @@ else { [#3 Content] = [#3 Removal] = [#3 Domain] = 6:0-8:1 -0| if (true) { - -1| - -2| } - -3| else if (false) { - -4| - -5| } - 6| else { >------ 7| diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.switchCase.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.switchCase.scope index 76e8c4831b..e613267613 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.switchCase.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.switchCase.scope @@ -5,27 +5,15 @@ switch (value) { [Content] = [Domain] = 1:2-1:13 -0| switch (value) { - 1| case 0: { } >-----------< -2| } - [Removal] = 1:0-1:13 -0| switch (value) { - 1| case 0: { } >-------------< -2| } - [Leading delimiter] = 1:0-1:2 -0| switch (value) { - 1| case 0: { } >--< -2| } - [Insertion delimiter] = "\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.try.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.try.scope index e42c7f19df..40723afd3f 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.try.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/branch.try.scope @@ -18,18 +18,6 @@ finally { 2| } -< -3| catch(error) { - -4| - -5| } - -6| finally { - -7| - -8| } - [#1 Insertion delimiter] = "\n" @@ -37,24 +25,12 @@ finally { [#2 Content] = [#2 Removal] = [#2 Domain] = 3:0-5:1 -0| try { - -1| - -2| } - 3| catch(error) { >-------------- 4| 5| } -< -6| finally { - -7| - -8| } - [#2 Insertion delimiter] = "\n" @@ -62,18 +38,6 @@ finally { [#3 Content] = [#3 Removal] = [#3 Domain] = 6:0-8:1 -0| try { - -1| - -2| } - -3| catch(error) { - -4| - -5| } - 6| finally { >--------- 7| diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/className.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/className.scope index 1e5100981c..6c8f825b9b 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/className.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/className.scope @@ -6,34 +6,18 @@ class MyClass { [Content] = 0:6-0:13 0| class MyClass { >-------< -1| - -2| } - [Removal] = 0:6-0:14 0| class MyClass { >--------< -1| - -2| } - [Leading delimiter] = 0:5-0:6 0| class MyClass { >-< -1| - -2| } - [Trailing delimiter] = 0:13-0:14 0| class MyClass { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| class MyClass { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.doWhile.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.doWhile.scope index 2a0e094add..df4978dfbf 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.doWhile.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.doWhile.scope @@ -5,10 +5,6 @@ do { [Content] = [Removal] = 2:9-2:13 -0| do { - -1| - 2| } while (true); >----< diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.for.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.for.scope index ad27ee3e82..7e6c9a90cc 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.for.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.for.scope @@ -6,26 +6,14 @@ for (let i = 0; i < 10; ++i) { [Content] = 0:16-0:22 0| for (let i = 0; i < 10; ++i) { >------< -1| - -2| } - [Removal] = 0:15-0:22 0| for (let i = 0; i < 10; ++i) { >-------< -1| - -2| } - [Leading delimiter] = 0:15-0:16 0| for (let i = 0; i < 10; ++i) { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| for (let i = 0; i < 10; ++i) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.if.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.if.scope index 2c4b7f91d4..c0e42c6b3e 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.if.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.if.scope @@ -7,10 +7,6 @@ if (true) { [Removal] = 0:4-0:8 0| if (true) { >----< -1| - -2| } - [Domain] = 0:0-2:1 0| if (true) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.switchCase.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.switchCase.scope index 165a5e3380..e88fccb478 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.switchCase.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.switchCase.scope @@ -4,35 +4,19 @@ switch (value) { --- [Content] = 1:7-1:8 -0| switch (value) { - 1| case 0: { } >-< -2| } - [Removal] = 1:6-1:8 -0| switch (value) { - 1| case 0: { } >--< -2| } - [Leading delimiter] = 1:6-1:7 -0| switch (value) { - 1| case 0: { } >-< -2| } - [Domain] = 1:2-1:13 -0| switch (value) { - 1| case 0: { } >-----------< -2| } - [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.while.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.while.scope index 0775aede9d..cac8942e85 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.while.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/condition.while.scope @@ -7,10 +7,6 @@ while (true) { [Removal] = 0:7-0:11 0| while (true) { >----< -1| - -2| } - [Domain] = 0:0-2:1 0| while (true) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/functionName.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/functionName.scope index 0534c5c56b..f2a9e5ea0b 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/functionName.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/functionName.scope @@ -7,18 +7,10 @@ function myFunk() { [Removal] = 0:9-0:15 0| function myFunk() { >------< -1| - -2| } - [Leading delimiter] = 0:8-0:9 0| function myFunk() { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| function myFunk() { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.class.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.class.scope index 1e5100981c..6c8f825b9b 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.class.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.class.scope @@ -6,34 +6,18 @@ class MyClass { [Content] = 0:6-0:13 0| class MyClass { >-------< -1| - -2| } - [Removal] = 0:6-0:14 0| class MyClass { >--------< -1| - -2| } - [Leading delimiter] = 0:5-0:6 0| class MyClass { >-< -1| - -2| } - [Trailing delimiter] = 0:13-0:14 0| class MyClass { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| class MyClass { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.field.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.field.scope index 7dd96ccff0..85f531b053 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.field.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.field.scope @@ -6,34 +6,18 @@ class MyClass { [#1 Content] = 0:6-0:13 0| class MyClass { >-------< -1| value = 0; - -2| } - [#1 Removal] = 0:6-0:14 0| class MyClass { >--------< -1| value = 0; - -2| } - [#1 Leading delimiter] = 0:5-0:6 0| class MyClass { >-< -1| value = 0; - -2| } - [#1 Trailing delimiter] = 0:13-0:14 0| class MyClass { >-< -1| value = 0; - -2| } - [#1 Domain] = 0:0-2:1 0| class MyClass { @@ -47,35 +31,19 @@ class MyClass { [#2 Content] = 1:2-1:7 -0| class MyClass { - 1| value = 0; >-----< -2| } - [#2 Removal] = 1:2-1:10 -0| class MyClass { - 1| value = 0; >--------< -2| } - [#2 Trailing delimiter] = 1:7-1:10 -0| class MyClass { - 1| value = 0; >---< -2| } - [#2 Domain] = 1:2-1:12 -0| class MyClass { - 1| value = 0; >----------< -2| } - [#2 Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.foreach.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.foreach.scope index 519f7e433b..00a66b9f00 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.foreach.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.foreach.scope @@ -6,34 +6,18 @@ for (const item of items) { [Content] = 0:11-0:15 0| for (const item of items) { >----< -1| - -2| } - [Removal] = 0:11-0:16 0| for (const item of items) { >-----< -1| - -2| } - [Leading delimiter] = 0:10-0:11 0| for (const item of items) { >-< -1| - -2| } - [Trailing delimiter] = 0:15-0:16 0| for (const item of items) { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| for (const item of items) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.function.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.function.scope index 0534c5c56b..f2a9e5ea0b 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.function.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/name.function.scope @@ -7,18 +7,10 @@ function myFunk() { [Removal] = 0:9-0:15 0| function myFunk() { >------< -1| - -2| } - [Leading delimiter] = 0:8-0:9 0| function myFunk() { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| function myFunk() { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/namedFunction.method.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/namedFunction.method.scope index 1d218d85bf..e27e640968 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/namedFunction.method.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/namedFunction.method.scope @@ -7,39 +7,23 @@ class MyClass { [Content] = [Domain] = 1:2-3:3 -0| class MyClass { - 1| myFunk() { >---------- 2| 3| } ---< -4| } - [Removal] = 1:0-3:3 -0| class MyClass { - 1| myFunk() { >------------ 2| 3| } ---< -4| } - [Leading delimiter] = 1:0-1:2 -0| class MyClass { - 1| myFunk() { >--< -2| - -3| } - -4| } - [Insertion delimiter] = "\n\n" diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/statement.iteration.document.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/statement.iteration.document.scope index ebb8ff812d..637148b86f 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/statement.iteration.document.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/statement.iteration.document.scope @@ -21,10 +21,6 @@ function foo() { [#2 Range] = [#2 Domain] = 2:16-4:0 -0| // Start - -1| - 2| function foo() { > 3| diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/switchStatementSubject.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/switchStatementSubject.scope index d05344ce2f..cb799aa2ef 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/switchStatementSubject.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/switchStatementSubject.scope @@ -7,10 +7,6 @@ switch (value) { [Removal] = 0:8-0:13 0| switch (value) { >-----< -1| - -2| } - [Domain] = 0:0-2:1 0| switch (value) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.field.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.field.scope index bb5227d2b7..4582ac2a3d 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.field.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.field.scope @@ -4,35 +4,19 @@ class MyClass { --- [Content] = 1:10-1:11 -0| class MyClass { - 1| value = 0; >-< -2| } - [Removal] = 1:7-1:11 -0| class MyClass { - 1| value = 0; >----< -2| } - [Leading delimiter] = 1:7-1:10 -0| class MyClass { - 1| value = 0; >---< -2| } - [Domain] = 1:2-1:12 -0| class MyClass { - 1| value = 0; >----------< -2| } - [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.foreach.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.foreach.scope index 11cf7e0034..37f1cff24e 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.foreach.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.foreach.scope @@ -6,26 +6,14 @@ for (const item of items) { [Content] = 0:19-0:24 0| for (const item of items) { >-----< -1| - -2| } - [Removal] = 0:18-0:24 0| for (const item of items) { >------< -1| - -2| } - [Leading delimiter] = 0:18-0:19 0| for (const item of items) { >-< -1| - -2| } - [Domain] = 0:0-2:1 0| for (const item of items) { diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.return.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.return.scope index 0ced004bf5..92d96256d5 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.return.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/javascript/value.return.scope @@ -4,35 +4,19 @@ function myFunk() { --- [Content] = 1:9-1:10 -0| function myFunk() { - 1| return 0; >-< -2| } - [Removal] = 1:8-1:10 -0| function myFunk() { - 1| return 0; >--< -2| } - [Leading delimiter] = 1:8-1:9 -0| function myFunk() { - 1| return 0; >-< -2| } - [Domain] = 1:2-1:11 -0| function myFunk() { - 1| return 0; >---------< -2| } - [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/name.foreach.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/name.foreach.scope index 724abf1fc6..183bba2818 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/name.foreach.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/name.foreach.scope @@ -5,26 +5,18 @@ for item in items: [Content] = 0:4-0:8 0| for item in items: >----< -1| pass - [Removal] = 0:4-0:9 0| for item in items: >-----< -1| pass - [Leading delimiter] = 0:3-0:4 0| for item in items: >-< -1| pass - [Trailing delimiter] = 0:8-0:9 0| for item in items: >-< -1| pass - [Domain] = 0:0-1:8 0| for item in items: diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/value.foreach.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/value.foreach.scope index 9c5ae8975c..611e59af23 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/value.foreach.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/python/value.foreach.scope @@ -5,20 +5,14 @@ for item in items: [Content] = 0:12-0:17 0| for item in items: >-----< -1| pass - [Removal] = 0:11-0:17 0| for item in items: >------< -1| pass - [Leading delimiter] = 0:11-0:12 0| for item in items: >-< -1| pass - [Domain] = 0:0-1:8 0| for item in items: diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/line2.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/line2.scope index aa70ecc82b..4c5e4d85f9 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/line2.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/line2.scope @@ -7,42 +7,28 @@ aaa [#1 Domain] = 0:0-0:0 0| >< -1| aaa - -2| - [#1 Removal] = 0:0-1:0 0| > 1| aaa < -2| - [#1 Trailing delimiter] = 0:0-1:0 0| > 1| aaa < -2| - [#1 Insertion delimiter] = "\n" [#2 Content] = [#2 Domain] = 1:0-1:3 -0| - 1| aaa >---< -2| - [#2 Removal] = 1:0-2:0 -0| - 1| aaa >--- 2| @@ -53,12 +39,8 @@ aaa > 1| aaa < -2| - [#2 Trailing delimiter] = 1:3-2:0 -0| - 1| aaa > 2| @@ -69,24 +51,16 @@ aaa [#3 Content] = [#3 Domain] = 2:0-2:0 -0| - -1| aaa - 2| >< [#3 Removal] = 1:3-2:0 -0| - 1| aaa > 2| < [#3 Leading delimiter] = 1:3-2:0 -0| - 1| aaa > 2| diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/paragraph.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/paragraph.scope index fb6b0a3fef..228b87ac8a 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/paragraph.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/textual/paragraph.scope @@ -6,14 +6,10 @@ bbb [Content] = [Domain] = 1:0-2:3 -0| - 1| aaa >--- 2| bbb ---< -3| - [Removal] = 0:0-3:0 0| @@ -28,36 +24,16 @@ bbb [Leading delimiter: Content] = 0:0-0:0 0| >< -1| aaa - -2| bbb - -3| - [Leading delimiter: Removal] = 0:0-1:0 0| > 1| aaa < -2| bbb - -3| - [Trailing delimiter: Content] = 3:0-3:0 -0| - -1| aaa - -2| bbb - 3| >< [Trailing delimiter: Removal] = 2:3-3:0 -0| - -1| aaa - 2| bbb > 3| diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.field.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.field.scope index 1ccca8391c..6f1fce4bb5 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.field.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.field.scope @@ -4,35 +4,19 @@ class MyClass { --- [Content] = 1:9-1:15 -0| class MyClass { - 1| value: number; >------< -2| } - [Removal] = 1:8-1:15 -0| class MyClass { - 1| value: number; >-------< -2| } - [Leading delimiter] = 1:8-1:9 -0| class MyClass { - 1| value: number; >-< -2| } - [Domain] = 1:2-1:16 -0| class MyClass { - 1| value: number; >--------------< -2| } - [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.formalParameter.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.formalParameter.scope index fd97f6f974..d87194715e 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.formalParameter.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.formalParameter.scope @@ -6,33 +6,17 @@ function myFunk(value: number) { [Content] = 0:23-0:29 0| function myFunk(value: number) { >------< -1| - -2| } - [Removal] = 0:21-0:29 0| function myFunk(value: number) { >--------< -1| - -2| } - [Leading delimiter] = 0:21-0:23 0| function myFunk(value: number) { >--< -1| - -2| } - [Domain] = 0:16-0:29 0| function myFunk(value: number) { >-------------< -1| - -2| } - [Insertion delimiter] = " " diff --git a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.return.scope b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.return.scope index 7aba31f954..c8aeca6b34 100644 --- a/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.return.scope +++ b/packages/cursorless-vscode-e2e/src/suite/fixtures/scopes/typescript/type.return.scope @@ -6,26 +6,14 @@ function myFunk(): number { [Content] = 0:19-0:25 0| function myFunk(): number { >------< -1| return 0; - -2| } - [Removal] = 0:17-0:25 0| function myFunk(): number { >--------< -1| return 0; - -2| } - [Leading delimiter] = 0:17-0:19 0| function myFunk(): number { >--< -1| return 0; - -2| } - [Domain] = 0:0-2:1 0| function myFunk(): number { diff --git a/packages/cursorless-vscode-e2e/src/suite/serializeTargetRange.ts b/packages/cursorless-vscode-e2e/src/suite/serializeTargetRange.ts index 13f5360478..b0cdc4abe8 100644 --- a/packages/cursorless-vscode-e2e/src/suite/serializeTargetRange.ts +++ b/packages/cursorless-vscode-e2e/src/suite/serializeTargetRange.ts @@ -36,28 +36,32 @@ export function serializeTargetRange( const lines: string[] = []; codeLines.forEach((codeLine, lineNumber) => { - // Output the line itself, prefixed by `n| `, eg `3| const foo = "bar"` - lines.push( - codeLine.length > 0 ? `${lineNumber}| ${codeLine}` : `${lineNumber}|`, - ); - + let annotationLine: string | undefined; if (lineNumber === start.line) { const prefix = fill(" ", start.character + 2) + ">"; if (start.line === end.line) { - lines.push(prefix + fill("-", end.character - start.character) + "<"); + annotationLine = + prefix + fill("-", end.character - start.character) + "<"; } else { - lines.push(prefix + fill("-", codeLine.length - start.character)); + annotationLine = prefix + fill("-", codeLine.length - start.character); } } else if (lineNumber > start.line && lineNumber < end.line) { if (codeLine.length > 0) { - lines.push(" " + fill("-", codeLine.length)); + annotationLine = " " + fill("-", codeLine.length); } else { - lines.push(""); + annotationLine = ""; } } else if (lineNumber === end.line) { - lines.push(" " + fill("-", end.character) + "<"); - } else { - lines.push(""); + annotationLine = " " + fill("-", end.character) + "<"; + } + + if (annotationLine != null) { + // Only output anything if there is an annotation line + lines.push( + // Output the line itself, prefixed by `n| `, eg `3| const foo = "bar"` + codeLine.length > 0 ? `${lineNumber}| ${codeLine}` : `${lineNumber}|`, + annotationLine, + ); } });