-
-
Notifications
You must be signed in to change notification settings - Fork 88
Fit interior range to content #715
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
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
0b786e9
Fit interior range to content
pokey 70cc54f
Merge branch 'main' into fitInteriorToContent
pokey 71e1e76
Merge branch 'main' into fitInteriorToContent
AndreasArvidsson 0336b56
Updated shrink range to fit content
AndreasArvidsson 53c0264
Added a lfcr test
AndreasArvidsson 07a6298
Added dock string
AndreasArvidsson 388d6b7
Merge branch 'main' into fitInteriorToContent
AndreasArvidsson b484376
Merge branch 'main' into fitInteriorToContent
pokey 49cdcdd
Added argument full interior range to interior target
AndreasArvidsson 2eea58a
Merge branch 'main' into fitInteriorToContent
AndreasArvidsson a6f4930
Updated test
AndreasArvidsson 744536f
Cleanup
AndreasArvidsson 8ab34dd
Update src/util/selectionUtils.ts
AndreasArvidsson 59d73bd
Update src/processTargets/targets/InteriorTarget.ts
AndreasArvidsson 075c1ad
Updated comment
AndreasArvidsson 812e33d
Added tests for empty and whitespace core
AndreasArvidsson a484a3a
Updated comment
AndreasArvidsson 142b6bb
Merge branch 'main' into fitInteriorToContent
pokey 6328a64
Empty commit
AndreasArvidsson File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import { Range } from "vscode"; | ||
import { shrinkRangeToFitContent } from "../../util/selectionUtils"; | ||
import BaseTarget, { CommonTargetParameters } from "./BaseTarget"; | ||
|
||
export interface InteriorTargetParameters | ||
extends Omit<CommonTargetParameters, "contentRange"> { | ||
readonly fullInteriorRange: Range; | ||
} | ||
|
||
export default class InteriorTarget extends BaseTarget { | ||
insertionDelimiter = " "; | ||
private readonly fullInteriorRange: Range; | ||
|
||
constructor(parameters: InteriorTargetParameters) { | ||
super({ | ||
...parameters, | ||
contentRange: shrinkRangeToFitContent( | ||
parameters.editor, | ||
parameters.fullInteriorRange | ||
), | ||
}); | ||
this.fullInteriorRange = parameters.fullInteriorRange; | ||
} | ||
|
||
getLeadingDelimiterTarget = () => undefined; | ||
getTrailingDelimiterTarget = () => undefined; | ||
getRemovalRange = () => this.fullInteriorRange; | ||
|
||
protected getCloneParameters() { | ||
return { | ||
...this.state, | ||
fullInteriorRange: this.fullInteriorRange, | ||
}; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/test/suite/fixtures/recorded/lineEndings/clearCoreFileLFCR.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
languageId: plaintext | ||
command: | ||
spokenForm: clear core file | ||
version: 2 | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- {type: interiorOnly} | ||
- type: containingScope | ||
scopeType: {type: document} | ||
usePrePhraseSnapshot: true | ||
action: {name: clearAndSetSelection} | ||
initialState: | ||
documentContents: "\r\n abc \r\n" | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} | ||
marks: {} | ||
finalState: | ||
documentContents: "\r\n \r\n" | ||
selections: | ||
- anchor: {line: 1, character: 1} | ||
active: {line: 1, character: 1} | ||
thatMark: | ||
- anchor: {line: 1, character: 1} | ||
active: {line: 1, character: 1} | ||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: interiorOnly}, {type: containingScope, scopeType: {type: document}}]}] |
25 changes: 25 additions & 0 deletions
25
src/test/suite/fixtures/recorded/selectionTypes/clearCore.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
languageId: plaintext | ||
command: | ||
spokenForm: clear core | ||
version: 2 | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- {type: interiorOnly} | ||
usePrePhraseSnapshot: true | ||
action: {name: clearAndSetSelection} | ||
initialState: | ||
documentContents: ( ) | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} | ||
marks: {} | ||
finalState: | ||
documentContents: () | ||
selections: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
thatMark: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: interiorOnly}]}] |
25 changes: 25 additions & 0 deletions
25
src/test/suite/fixtures/recorded/selectionTypes/clearCore2.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
languageId: plaintext | ||
command: | ||
spokenForm: clear core | ||
version: 2 | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- {type: interiorOnly} | ||
usePrePhraseSnapshot: true | ||
action: {name: clearAndSetSelection} | ||
initialState: | ||
documentContents: () | ||
selections: | ||
- anchor: {line: 0, character: 0} | ||
active: {line: 0, character: 0} | ||
marks: {} | ||
finalState: | ||
documentContents: () | ||
selections: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
thatMark: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: interiorOnly}]}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/test/suite/fixtures/recorded/surroundingPair/chuckCore.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
languageId: typescript | ||
command: | ||
spokenForm: chuck core | ||
version: 2 | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- {type: interiorOnly} | ||
usePrePhraseSnapshot: true | ||
action: {name: remove} | ||
initialState: | ||
documentContents: |- | ||
[ | ||
"foo", | ||
"bar" | ||
] | ||
selections: | ||
- anchor: {line: 1, character: 10} | ||
active: {line: 1, character: 10} | ||
marks: {} | ||
finalState: | ||
documentContents: "[]" | ||
selections: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
thatMark: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: interiorOnly}]}] |
25 changes: 25 additions & 0 deletions
25
src/test/suite/fixtures/recorded/surroundingPair/chuckCore2.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
languageId: plaintext | ||
command: | ||
spokenForm: chuck core | ||
version: 2 | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- {type: interiorOnly} | ||
usePrePhraseSnapshot: true | ||
action: {name: remove} | ||
initialState: | ||
documentContents: ( hello ) | ||
selections: | ||
- anchor: {line: 0, character: 6} | ||
active: {line: 0, character: 6} | ||
marks: {} | ||
finalState: | ||
documentContents: () | ||
selections: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
thatMark: | ||
- anchor: {line: 0, character: 1} | ||
active: {line: 0, character: 1} | ||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: interiorOnly}]}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/test/suite/fixtures/recorded/surroundingPair/takeCore.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
languageId: typescript | ||
command: | ||
spokenForm: take core | ||
version: 2 | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- {type: interiorOnly} | ||
usePrePhraseSnapshot: true | ||
action: {name: setSelection} | ||
initialState: | ||
documentContents: |- | ||
[ | ||
"foo", | ||
"bar" | ||
] | ||
selections: | ||
- anchor: {line: 1, character: 10} | ||
active: {line: 1, character: 10} | ||
marks: {} | ||
finalState: | ||
documentContents: |- | ||
[ | ||
"foo", | ||
"bar" | ||
] | ||
selections: | ||
- anchor: {line: 1, character: 4} | ||
active: {line: 2, character: 9} | ||
thatMark: | ||
- anchor: {line: 1, character: 4} | ||
active: {line: 2, character: 9} | ||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: interiorOnly}]}] |
25 changes: 25 additions & 0 deletions
25
src/test/suite/fixtures/recorded/surroundingPair/takeCore2.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
languageId: plaintext | ||
command: | ||
spokenForm: take core | ||
version: 2 | ||
targets: | ||
- type: primitive | ||
modifiers: | ||
- {type: interiorOnly} | ||
usePrePhraseSnapshot: true | ||
action: {name: setSelection} | ||
initialState: | ||
documentContents: ( hello ) | ||
selections: | ||
- anchor: {line: 0, character: 6} | ||
active: {line: 0, character: 6} | ||
marks: {} | ||
finalState: | ||
documentContents: ( hello ) | ||
selections: | ||
- anchor: {line: 0, character: 2} | ||
active: {line: 0, character: 7} | ||
thatMark: | ||
- anchor: {line: 0, character: 2} | ||
active: {line: 0, character: 7} | ||
fullTargets: [{type: primitive, mark: {type: cursor}, modifiers: [{type: interiorOnly}]}] |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.