Skip to content

Commit 92c73f7

Browse files
Support arbitrary scope and insertion delimiter for drop, float and puff (#2646)
This new implementation allows us to do things like `"puff token"` to insert spaces. `"float item"` to insert `, ` etc. A bit like #2651. This new implementation also fixed a few bugs around where the selection and highlights ended up. Note that there is still a bug with the range updater when you have an empty selection, but that is out of scope for this pr. #729 Fixes #742 ## Checklist - [x] 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 --------- Co-authored-by: Phil Cohen <[email protected]>
1 parent 9cf3a1b commit 92c73f7

32 files changed

+317
-172
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
tags: [enhancement]
3+
pullRequest: 2646
4+
---
5+
6+
`drop`, `float` and `puff` now behave like `drink` and `pour` for non-line targets: for example, `"puff token"` will insert spaces around the token; `"float item"` will insert `,`s as needed, and so on.
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
languageId: plaintext
2+
command:
3+
version: 7
4+
spokenForm: drop token
5+
action:
6+
name: insertEmptyLineBefore
7+
target:
8+
type: primitive
9+
modifiers:
10+
- type: containingScope
11+
scopeType: {type: token}
12+
usePrePhraseSnapshot: true
13+
initialState:
14+
documentContents: foo
15+
selections:
16+
- anchor: {line: 0, character: 0}
17+
active: {line: 0, character: 0}
18+
marks: {}
19+
finalState:
20+
documentContents: " foo"
21+
selections:
22+
- anchor: {line: 0, character: 1}
23+
active: {line: 0, character: 1}
24+
thatMark:
25+
- type: UntypedTarget
26+
contentRange:
27+
start: {line: 0, character: 1}
28+
end: {line: 0, character: 4}
29+
isReversed: false
30+
hasExplicitRange: true

data/fixtures/recorded/actions/insertEmptyLines/floatThis.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ finalState:
1818
documentContents: |+
1919
2020
selections:
21-
- anchor: {line: 1, character: 0}
22-
active: {line: 1, character: 0}
21+
- anchor: {line: 0, character: 0}
22+
active: {line: 0, character: 0}
2323
thatMark:
2424
- type: UntypedTarget
2525
contentRange:
26-
start: {line: 1, character: 0}
27-
end: {line: 1, character: 0}
26+
start: {line: 0, character: 0}
27+
end: {line: 0, character: 0}
2828
isReversed: false
2929
hasExplicitRange: true
3030
ide:

data/fixtures/recorded/actions/insertEmptyLines/floatThis10.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ finalState:
2121
2222
hello
2323
selections:
24-
- anchor: {line: 2, character: 0}
25-
active: {line: 2, character: 0}
24+
- anchor: {line: 1, character: 9}
25+
active: {line: 1, character: 9}
2626
thatMark:
2727
- type: UntypedTarget
2828
contentRange:
29-
start: {line: 2, character: 0}
30-
end: {line: 2, character: 0}
29+
start: {line: 1, character: 9}
30+
end: {line: 1, character: 9}
3131
isReversed: false
3232
hasExplicitRange: true
3333
ide:

data/fixtures/recorded/actions/insertEmptyLines/floatThis2.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ finalState:
1818
documentContents: |
1919
hello
2020
selections:
21-
- anchor: {line: 1, character: 0}
22-
active: {line: 1, character: 0}
21+
- anchor: {line: 0, character: 5}
22+
active: {line: 0, character: 5}
2323
thatMark:
2424
- type: UntypedTarget
2525
contentRange:
26-
start: {line: 1, character: 0}
27-
end: {line: 1, character: 0}
26+
start: {line: 0, character: 5}
27+
end: {line: 0, character: 5}
2828
isReversed: false
2929
hasExplicitRange: true
3030
ide:

data/fixtures/recorded/actions/insertEmptyLines/floatThis3.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ finalState:
1818
documentContents: |2
1919
hello
2020
selections:
21-
- anchor: {line: 1, character: 0}
22-
active: {line: 1, character: 0}
21+
- anchor: {line: 0, character: 9}
22+
active: {line: 0, character: 9}
2323
thatMark:
2424
- type: UntypedTarget
2525
contentRange:
26-
start: {line: 1, character: 0}
27-
end: {line: 1, character: 0}
26+
start: {line: 0, character: 9}
27+
end: {line: 0, character: 9}
2828
isReversed: false
2929
hasExplicitRange: true
3030
ide:

data/fixtures/recorded/actions/insertEmptyLines/floatThis4.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@ finalState:
1818
documentContents: |2
1919
2020
selections:
21-
- anchor: {line: 1, character: 0}
22-
active: {line: 1, character: 0}
21+
- anchor: {line: 0, character: 4}
22+
active: {line: 0, character: 4}
2323
thatMark:
2424
- type: UntypedTarget
2525
contentRange:
26-
start: {line: 1, character: 0}
27-
end: {line: 1, character: 0}
26+
start: {line: 0, character: 4}
27+
end: {line: 0, character: 4}
2828
isReversed: false
2929
hasExplicitRange: true
3030
ide:

data/fixtures/recorded/actions/insertEmptyLines/floatThis5.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ finalState:
2121
whatever
2222
hello
2323
selections:
24-
- anchor: {line: 2, character: 0}
25-
active: {line: 2, character: 0}
24+
- anchor: {line: 1, character: 9}
25+
active: {line: 1, character: 9}
2626
thatMark:
2727
- type: UntypedTarget
2828
contentRange:
29-
start: {line: 2, character: 0}
30-
end: {line: 2, character: 0}
29+
start: {line: 1, character: 9}
30+
end: {line: 1, character: 9}
3131
isReversed: false
3232
hasExplicitRange: true
3333
ide:

data/fixtures/recorded/actions/insertEmptyLines/floatThis6.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ finalState:
2121
whatever
2222
hello
2323
selections:
24-
- anchor: {line: 2, character: 0}
25-
active: {line: 2, character: 0}
24+
- anchor: {line: 1, character: 5}
25+
active: {line: 1, character: 5}
2626
thatMark:
2727
- type: UntypedTarget
2828
contentRange:
29-
start: {line: 2, character: 0}
30-
end: {line: 2, character: 0}
29+
start: {line: 1, character: 5}
30+
end: {line: 1, character: 5}
3131
isReversed: false
3232
hasExplicitRange: true
3333
ide:

data/fixtures/recorded/actions/insertEmptyLines/floatThis7.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ finalState:
2020
hello
2121
2222
selections:
23-
- anchor: {line: 2, character: 0}
24-
active: {line: 2, character: 0}
23+
- anchor: {line: 1, character: 0}
24+
active: {line: 1, character: 0}
2525
thatMark:
2626
- type: UntypedTarget
2727
contentRange:
28-
start: {line: 2, character: 0}
29-
end: {line: 2, character: 0}
28+
start: {line: 1, character: 0}
29+
end: {line: 1, character: 0}
3030
isReversed: false
3131
hasExplicitRange: true
3232
ide:

0 commit comments

Comments
 (0)