Skip to content

Updated leading and trailing delimiters for before and after positions #340

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 29, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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}}]