Skip to content

Commit c47fa93

Browse files
committed
Fix bug and add a bunch of tests
1 parent c89158c commit c47fa93

File tree

14 files changed

+229
-56
lines changed

14 files changed

+229
-56
lines changed

src/processTargets/processSelectionType.ts

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,22 @@ function processToken(
7777
selectionType,
7878
position,
7979
insideOutsideType,
80-
selectionContext: getTokenSelectionContext(
81-
selection,
82-
modifier,
83-
position,
84-
insideOutsideType,
85-
selectionContext
86-
),
80+
// NB: This is a hack to work around the fact that it's not currently
81+
// possible to apply a modifier after processing the selection type. We
82+
// would really prefer that the user be able to say "just" and have that be
83+
// processed after we've processed the selection type, which would strip
84+
// away the type information and turn it into a raw target. Until that's
85+
// possible using the new pipelines, we instead just check for it here when
86+
// we're doing the selection type and bail out if it is a raw target.
87+
selectionContext: selectionContext.isRawSelection
88+
? selectionContext
89+
: getTokenSelectionContext(
90+
selection,
91+
modifier,
92+
position,
93+
insideOutsideType,
94+
selectionContext
95+
),
8796
};
8897
}
8998

src/test/suite/fixtures/recorded/actions/bringAirAndBatAndCap.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,7 @@ command:
1212
mark: {type: decoratedSymbol, symbolColor: default, character: b}
1313
- type: primitive
1414
mark: {type: decoratedSymbol, symbolColor: default, character: c}
15-
- type: primitive
16-
mark: {type: cursor}
17-
selectionType: token
18-
position: contents
19-
modifier: {type: identity}
20-
insideOutsideType: inside
15+
- {type: primitive, isImplicit: true}
2116
initialState:
2217
documentContents: |+
2318
a
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
languageId: typescript
2+
command:
3+
version: 1
4+
spokenForm: bring argue fine and zip
5+
action: replaceWithTarget
6+
targets:
7+
- type: list
8+
elements:
9+
- type: primitive
10+
modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}
11+
mark: {type: decoratedSymbol, symbolColor: default, character: f}
12+
- type: primitive
13+
mark: {type: decoratedSymbol, symbolColor: default, character: z}
14+
- {type: primitive, isImplicit: true}
15+
initialState:
16+
documentContents: |-
17+
function helloWorld(foo: string, bar: number, baz: string) {
18+
19+
}
20+
21+
function bongo() {
22+
23+
}
24+
selections:
25+
- anchor: {line: 4, character: 15}
26+
active: {line: 4, character: 15}
27+
marks:
28+
default.f:
29+
start: {line: 0, character: 20}
30+
end: {line: 0, character: 23}
31+
default.z:
32+
start: {line: 0, character: 46}
33+
end: {line: 0, character: 49}
34+
finalState:
35+
documentContents: |-
36+
function helloWorld(foo: string, bar: number, baz: string) {
37+
38+
}
39+
40+
function bongo(foo: string, baz: string) {
41+
42+
}
43+
selections:
44+
- anchor: {line: 4, character: 39}
45+
active: {line: 4, character: 39}
46+
thatMark:
47+
- anchor: {line: 4, character: 15}
48+
active: {line: 4, character: 39}
49+
sourceMark:
50+
- anchor: {line: 0, character: 20}
51+
active: {line: 0, character: 31}
52+
- anchor: {line: 0, character: 46}
53+
active: {line: 0, character: 57}
54+
fullTargets: [{type: list, elements: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: f}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: z}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}]}, {type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}, isImplicit: true}]
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
languageId: typescript
2+
command:
3+
version: 1
4+
spokenForm: bring argue ox and zip to after just leper
5+
action: replaceWithTarget
6+
targets:
7+
- type: list
8+
elements:
9+
- type: primitive
10+
modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}
11+
mark: {type: decoratedSymbol, symbolColor: default, character: o}
12+
- type: primitive
13+
mark: {type: decoratedSymbol, symbolColor: default, character: z}
14+
- type: primitive
15+
position: after
16+
modifier: {type: toRawSelection}
17+
mark: {type: decoratedSymbol, symbolColor: default, character: (}
18+
initialState:
19+
documentContents: |-
20+
function helloWorld(foo: string, bar: number, baz: string) {
21+
22+
}
23+
24+
function bongo() {
25+
26+
}
27+
selections:
28+
- anchor: {line: 3, character: 0}
29+
active: {line: 3, character: 0}
30+
marks:
31+
default.o:
32+
start: {line: 0, character: 20}
33+
end: {line: 0, character: 23}
34+
default.z:
35+
start: {line: 0, character: 46}
36+
end: {line: 0, character: 49}
37+
default.(:
38+
start: {line: 4, character: 14}
39+
end: {line: 4, character: 15}
40+
finalState:
41+
documentContents: |-
42+
function helloWorld(foo: string, bar: number, baz: string) {
43+
44+
}
45+
46+
function bongo(foo: string, baz: string) {
47+
48+
}
49+
selections:
50+
- anchor: {line: 3, character: 0}
51+
active: {line: 3, character: 0}
52+
thatMark:
53+
- anchor: {line: 4, character: 15}
54+
active: {line: 4, character: 39}
55+
sourceMark:
56+
- anchor: {line: 0, character: 20}
57+
active: {line: 0, character: 31}
58+
- anchor: {line: 0, character: 46}
59+
active: {line: 0, character: 57}
60+
fullTargets: [{type: list, elements: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: o}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: z}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: containingScope, scopeType: argumentOrParameter, includeSiblings: false}, isImplicit: false}]}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: (}, selectionType: token, position: after, insideOutsideType: null, modifier: {type: toRawSelection}, isImplicit: false}]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
languageId: plaintext
2+
command:
3+
version: 1
4+
spokenForm: bring line harp and whale
5+
action: replaceWithTarget
6+
targets:
7+
- type: list
8+
elements:
9+
- type: primitive
10+
selectionType: line
11+
mark: {type: decoratedSymbol, symbolColor: default, character: h}
12+
- type: primitive
13+
mark: {type: decoratedSymbol, symbolColor: default, character: w}
14+
- {type: primitive, isImplicit: true}
15+
initialState:
16+
documentContents: |+
17+
hello
18+
there
19+
whatever
20+
21+
selections:
22+
- anchor: {line: 4, character: 0}
23+
active: {line: 4, character: 0}
24+
marks:
25+
default.h:
26+
start: {line: 0, character: 0}
27+
end: {line: 0, character: 5}
28+
default.w:
29+
start: {line: 2, character: 0}
30+
end: {line: 2, character: 8}
31+
finalState:
32+
documentContents: |-
33+
hello
34+
there
35+
whatever
36+
37+
hello
38+
whatever
39+
selections:
40+
- anchor: {line: 5, character: 8}
41+
active: {line: 5, character: 8}
42+
thatMark:
43+
- anchor: {line: 4, character: 0}
44+
active: {line: 5, character: 8}
45+
sourceMark:
46+
- anchor: {line: 0, character: 0}
47+
active: {line: 0, character: 5}
48+
- anchor: {line: 2, character: 0}
49+
active: {line: 2, character: 8}
50+
fullTargets: [{type: list, elements: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: h}, selectionType: line, position: contents, insideOutsideType: null, modifier: {type: identity}, isImplicit: false}, {type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: w}, selectionType: line, position: contents, insideOutsideType: null, modifier: {type: identity}, isImplicit: false}]}, {type: primitive, mark: {type: cursor}, selectionType: token, position: contents, insideOutsideType: null, modifier: {type: identity}, isImplicit: true}]

src/test/suite/fixtures/recorded/actions/bringVest.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ command:
66
targets:
77
- type: primitive
88
mark: {type: decoratedSymbol, symbolColor: default, character: v}
9-
- type: primitive
10-
mark: {type: cursor}
11-
selectionType: token
12-
position: contents
13-
modifier: {type: identity}
14-
insideOutsideType: inside
9+
- {type: primitive, isImplicit: true}
1510
initialState:
1611
documentContents: |
1712

src/test/suite/fixtures/recorded/actions/callFine.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ command:
66
targets:
77
- type: primitive
88
mark: {type: decoratedSymbol, symbolColor: default, character: f}
9-
- type: primitive
10-
mark: {type: cursor}
11-
selectionType: token
12-
position: contents
13-
modifier: {type: identity}
14-
insideOutsideType: inside
9+
- {type: primitive, isImplicit: true}
1510
initialState:
1611
documentContents: |-
1712
foo;

src/test/suite/fixtures/recorded/actions/callVest.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ command:
66
targets:
77
- type: primitive
88
mark: {type: decoratedSymbol, symbolColor: default, character: v}
9-
- type: primitive
10-
mark: {type: cursor}
11-
selectionType: token
12-
position: contents
13-
modifier: {type: identity}
14-
insideOutsideType: inside
9+
- {type: primitive, isImplicit: true}
1510
initialState:
1611
documentContents: |
1712

src/test/suite/fixtures/recorded/actions/moveVest.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ command:
66
targets:
77
- type: primitive
88
mark: {type: decoratedSymbol, symbolColor: default, character: v}
9-
- type: primitive
10-
mark: {type: cursor}
11-
selectionType: token
12-
position: contents
13-
modifier: {type: identity}
14-
insideOutsideType: inside
9+
- {type: primitive, isImplicit: true}
1510
initialState:
1611
documentContents: |
1712

src/test/suite/fixtures/recorded/hatTokenMap/bringHarpTakeWhale.yml

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,7 @@ command:
66
targets:
77
- type: primitive
88
mark: {type: decoratedSymbol, symbolColor: default, character: h}
9-
- type: primitive
10-
mark: {type: cursor}
11-
selectionType: token
12-
position: contents
13-
modifier: {type: identity}
14-
insideOutsideType: inside
9+
- {type: primitive, isImplicit: true}
1510
marksToCheck: [default.w]
1611
initialState:
1712
documentContents: hello world

0 commit comments

Comments
 (0)