Skip to content

Commit

Permalink
Updated leading and trailing delimiters for before and after positions (
Browse files Browse the repository at this point in the history
#340)

Co-authored-by: Pokey Rule <pokey.rule@gmail.com>
  • Loading branch information
AndreasArvidsson and pokey authored Nov 29, 2021
1 parent de7dfef commit 5cdb954
Show file tree
Hide file tree
Showing 7 changed files with 219 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/processTargets/processSelectionType.ts
Original file line number Diff line number Diff line change
Expand Up @@ -213,10 +213,16 @@ function getTokenSelectionContext(
: null;
}

const isInDelimitedList =
(leadingDelimiterRange != null || trailingDelimiterRange != null) &&
(leadingDelimiterRange != null || start.character === 0) &&
(trailingDelimiterRange != null || end.isEqual(endLine.range.end));
let isInDelimitedList;
if (position === "contents") {
isInDelimitedList =
(leadingDelimiterRange != null || trailingDelimiterRange != null) &&
(leadingDelimiterRange != null || start.character === 0) &&
(trailingDelimiterRange != null || end.isEqual(endLine.range.end));
} else {
isInDelimitedList =
leadingDelimiterRange != null || trailingDelimiterRange != null;
}

return {
isInDelimitedList,
Expand Down
35 changes: 35 additions & 0 deletions src/test/suite/fixtures/recorded/positions/chuckAfterHarp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
spokenForm: chuck after harp
languageId: typescript
command:
actionName: remove
partialTargets:
- type: primitive
position: after
mark: {type: decoratedSymbol, symbolColor: default, character: h}
extraArgs: []
initialState:
documentContents: |
"hello "
" hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
marks:
default.h:
start: {line: 2, character: 2}
end: {line: 2, character: 7}
finalState:
documentContents: |
"hello "
" hello"
" hello"
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
thatMark:
- anchor: {line: 2, character: 7}
active: {line: 2, character: 7}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: h}, selectionType: token, position: after, insideOutsideType: outside, modifier: {type: identity}}]
35 changes: 35 additions & 0 deletions src/test/suite/fixtures/recorded/positions/chuckAfterLook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
spokenForm: chuck after look
languageId: typescript
command:
actionName: remove
partialTargets:
- type: primitive
position: after
mark: {type: decoratedSymbol, symbolColor: default, character: l}
extraArgs: []
initialState:
documentContents: |
"hello "
" hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
marks:
default.l:
start: {line: 0, character: 1}
end: {line: 0, character: 6}
finalState:
documentContents: |
"hello"
" hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
thatMark:
- anchor: {line: 0, character: 6}
active: {line: 0, character: 6}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: l}, selectionType: token, position: after, insideOutsideType: outside, modifier: {type: identity}}]
34 changes: 34 additions & 0 deletions src/test/suite/fixtures/recorded/positions/chuckAir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
spokenForm: chuck air
languageId: typescript
command:
actionName: remove
partialTargets:
- type: primitive
mark: {type: decoratedSymbol, symbolColor: default, character: a}
extraArgs: []
initialState:
documentContents: |
"hello "
" hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
marks:
default.a:
start: {line: 3, character: 7}
end: {line: 3, character: 8}
finalState:
documentContents: |
"hello "
" hello"
" hello "
return .b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
thatMark:
- anchor: {line: 3, character: 7}
active: {line: 3, character: 7}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: contents, insideOutsideType: outside, modifier: {type: identity}}]
35 changes: 35 additions & 0 deletions src/test/suite/fixtures/recorded/positions/chuckBeforeAir.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
spokenForm: chuck before air
languageId: typescript
command:
actionName: remove
partialTargets:
- type: primitive
position: before
mark: {type: decoratedSymbol, symbolColor: default, character: a}
extraArgs: []
initialState:
documentContents: |
"hello "
" hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
marks:
default.a:
start: {line: 3, character: 7}
end: {line: 3, character: 8}
finalState:
documentContents: |
"hello "
" hello"
" hello "
returna.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
thatMark:
- anchor: {line: 3, character: 6}
active: {line: 3, character: 6}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: a}, selectionType: token, position: before, insideOutsideType: outside, modifier: {type: identity}}]
35 changes: 35 additions & 0 deletions src/test/suite/fixtures/recorded/positions/chuckBeforeEach.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
spokenForm: chuck before each
languageId: typescript
command:
actionName: remove
partialTargets:
- type: primitive
position: before
mark: {type: decoratedSymbol, symbolColor: default, character: e}
extraArgs: []
initialState:
documentContents: |
"hello "
" hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
marks:
default.e:
start: {line: 1, character: 2}
end: {line: 1, character: 7}
finalState:
documentContents: |
"hello "
"hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
thatMark:
- anchor: {line: 1, character: 1}
active: {line: 1, character: 1}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: e}, selectionType: token, position: before, insideOutsideType: outside, modifier: {type: identity}}]
35 changes: 35 additions & 0 deletions src/test/suite/fixtures/recorded/positions/chuckBeforeHarp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
spokenForm: chuck before harp
languageId: typescript
command:
actionName: remove
partialTargets:
- type: primitive
position: before
mark: {type: decoratedSymbol, symbolColor: default, character: h}
extraArgs: []
initialState:
documentContents: |
"hello "
" hello"
" hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
marks:
default.h:
start: {line: 2, character: 2}
end: {line: 2, character: 7}
finalState:
documentContents: |
"hello "
" hello"
"hello "
return a.b
selections:
- anchor: {line: 4, character: 0}
active: {line: 4, character: 0}
thatMark:
- anchor: {line: 2, character: 1}
active: {line: 2, character: 1}
fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: h}, selectionType: token, position: before, insideOutsideType: outside, modifier: {type: identity}}]

0 comments on commit 5cdb954

Please sign in to comment.