-
-
Notifications
You must be signed in to change notification settings - Fork 93
Add cell selection type #246
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
5 commits
Select commit
Hold shift + click to select a range
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| import { ActionType, PartialTarget, SelectionType } from "./typings/Types"; | ||
| import { getPrimitiveTargets } from "./util/targetUtils"; | ||
|
|
||
| export function checkCommandValidity( | ||
| actionName: ActionType, | ||
| partialTargets: PartialTarget[], | ||
| extraArgs: any[] | ||
| ) { | ||
| if ( | ||
| usesSelectionType("notebookCell", partialTargets) && | ||
| !["editNewLineAbove", "editNewLineBelow"].includes(actionName) | ||
| ) { | ||
| throw new Error( | ||
| "The notebookCell scope type is currently only supported with the actions editNewLineAbove and editNewLineBelow" | ||
| ); | ||
| } | ||
| } | ||
|
|
||
| function usesSelectionType( | ||
| selectionType: SelectionType, | ||
| partialTargets: PartialTarget[] | ||
| ) { | ||
| return getPrimitiveTargets(partialTargets).some( | ||
| (partialTarget) => partialTarget.selectionType === selectionType | ||
| ); | ||
| } |
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
27 changes: 27 additions & 0 deletions
27
src/test/suite/fixtures/recorded/selectionTypes/drinkCell.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 @@ | ||
| # Note that this is just checking that no errors are thrown | ||
| spokenForm: drink cell | ||
| languageId: python | ||
| command: | ||
| actionName: editNewLineAbove | ||
| partialTargets: | ||
| - {type: primitive, selectionType: notebookCell} | ||
| extraArgs: [] | ||
| marks: {} | ||
| initialState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 1, character: 12} | ||
| active: {line: 1, character: 12} | ||
| finalState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 1, character: 0} | ||
| active: {line: 1, character: 0} | ||
| thatMark: | ||
| - anchor: {line: 1, character: 0} | ||
| active: {line: 1, character: 0} | ||
| fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: notebookCell, position: contents, insideOutsideType: inside, modifier: {type: identity}}] | ||
38 changes: 38 additions & 0 deletions
38
src/test/suite/fixtures/recorded/selectionTypes/drinkCellEach.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,38 @@ | ||
| # Note that this is just checking that no errors are thrown | ||
| spokenForm: drink cell each | ||
| languageId: python | ||
| command: | ||
| actionName: editNewLineAbove | ||
| partialTargets: | ||
| - type: primitive | ||
| selectionType: notebookCell | ||
| mark: {type: decoratedSymbol, symbolColor: default, character: e} | ||
| extraArgs: [] | ||
| marks: | ||
| default.e: | ||
| start: {line: 1, character: 7} | ||
| end: {line: 1, character: 12} | ||
| initialState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
|
|
||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 4, character: 12} | ||
| active: {line: 4, character: 12} | ||
| finalState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
|
|
||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 1, character: 0} | ||
| active: {line: 1, character: 0} | ||
| thatMark: | ||
| - anchor: {line: 1, character: 0} | ||
| active: {line: 1, character: 0} | ||
| fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: e}, selectionType: notebookCell, position: contents, insideOutsideType: inside, modifier: {type: identity}}] |
27 changes: 27 additions & 0 deletions
27
src/test/suite/fixtures/recorded/selectionTypes/pourCell.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 @@ | ||
| # Note that this is just checking that no errors are thrown | ||
| spokenForm: pour cell | ||
| languageId: python | ||
| command: | ||
| actionName: editNewLineBelow | ||
| partialTargets: | ||
| - {type: primitive, selectionType: notebookCell} | ||
| extraArgs: [] | ||
| marks: {} | ||
| initialState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 1, character: 12} | ||
| active: {line: 1, character: 12} | ||
| finalState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 3, character: 0} | ||
| active: {line: 3, character: 0} | ||
| thatMark: | ||
| - anchor: {line: 3, character: 0} | ||
| active: {line: 3, character: 0} | ||
| fullTargets: [{type: primitive, mark: {type: cursor}, selectionType: notebookCell, position: contents, insideOutsideType: inside, modifier: {type: identity}}] |
38 changes: 38 additions & 0 deletions
38
src/test/suite/fixtures/recorded/selectionTypes/pourCellEach.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,38 @@ | ||
| # Note that this is just checking that no errors are thrown | ||
| spokenForm: pour cell each | ||
| languageId: python | ||
| command: | ||
| actionName: editNewLineBelow | ||
| partialTargets: | ||
| - type: primitive | ||
| selectionType: notebookCell | ||
| mark: {type: decoratedSymbol, symbolColor: default, character: e} | ||
| extraArgs: [] | ||
| marks: | ||
| default.e: | ||
| start: {line: 1, character: 7} | ||
| end: {line: 1, character: 12} | ||
| initialState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
|
|
||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 4, character: 12} | ||
| active: {line: 4, character: 12} | ||
| finalState: | ||
| documentContents: |- | ||
| # %% | ||
| print("hello") | ||
|
|
||
| # %% | ||
| print("hello") | ||
| selections: | ||
| - anchor: {line: 4, character: 0} | ||
| active: {line: 4, character: 0} | ||
| thatMark: | ||
| - anchor: {line: 4, character: 0} | ||
| active: {line: 4, character: 0} | ||
| fullTargets: [{type: primitive, mark: {type: decoratedSymbol, symbolColor: default, character: e}, selectionType: notebookCell, position: contents, insideOutsideType: inside, modifier: {type: identity}}] |
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
whoops. looks like (shockingly) the
jupyter.insertCellAbovecommand returns a promise that resolves before the action is actually complete, so test recorder shows nothing having changed. awesome. so do we keep the test to just make sure nothing errors, delete the test, or insert some random sleep? cc/ @AndreasArvidsson @brxckThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wtf they dont ubderstand how a promise work do they?
I dont really care since we cant actually test it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yikes. If it were up to me I would leave the test as is with a note. I don't think it's worth it to accommodate with a sleep, we're never going to be 100% tests anyhow.