-
Notifications
You must be signed in to change notification settings - Fork 337
add run above and run below to native notebooks #4240
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
Conversation
commandManager.registerCommand(Commands.NativeNotebookRunCellAndAllBelow, (uri) => | ||
this.runCellAndBelow(uri) | ||
) | ||
); |
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.
In old notebooks, the buttons are enabled only when the user selects a cell. In this case I don't know if we can do that.
We can create the context for it, but there's no event to keep it updated.
package.json
Outdated
@@ -279,6 +279,26 @@ | |||
}, | |||
"enablement": "notebookViewType == jupyter-notebook && jupyter.isnotebooktrusted" | |||
}, | |||
{ | |||
"command": "jupyter.notebookEditor.runallcellsabove", |
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.
From what I can see we don't camelCase any other command names. So should keep "notebookeditor" here for consistancy.
@@ -394,6 +394,8 @@ | |||
"DataScience.insertAbove": "Insert cell above", | |||
"DataScience.addCell": "Add cell", | |||
"DataScience.runAll": "Run all cells", | |||
"DataScience.runAbove": "Run cells above", |
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.
We already have some command titles from the old code. Do any of the old strings work here so that we don't need to add new ones?
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.
We never had, the ones on toolbar.tsx for example were returning a default.
There are messages for the command palette:
"jupyter.command.jupyter.runallcellsabove.palette.title": "Run Cells Above Current Cell",
"jupyter.command.jupyter.runcurrentcellandallbelow.palette.title": "Run Current Cell and Below",
Should I use those instead? They're a bit different
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.
Hmmm, maybe just leave as is then. Keeps the native notebook stuff separate.
src/client/datascience/constants.ts
Outdated
@@ -49,6 +49,8 @@ export namespace Commands { | |||
export const RunAllCells = 'jupyter.runallcells'; | |||
export const RunAllCellsAbove = 'jupyter.runallcellsabove'; | |||
export const RunCellAndAllBelow = 'jupyter.runcellandallbelow'; | |||
export const NativeNotebookRunAllCellsAbove = 'jupyter.notebookEditor.runallcellsabove'; |
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.
notebookEditor change to notebookeditor here as well.
return editor.selection.uri.toString(); | ||
} | ||
|
||
return ''; |
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.
I'd make this function return string or undefined. While '' can work as a "not found value" the undefined make it more clear that you have something valid any string is returned and something not valid if undefined. Even if both empty string and undefined are falsy.
|
||
cells.forEach(async (cell) => { | ||
// 2 means code cell | ||
if (cell.cellKind === 2) { |
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.
You can use the enum here I think:
vscodeNotebookEnums.CellKind.Code
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.
David. Code looks solid here to me with a few small suggestions. I do think that we should see about adding in a .vscode. test here for this functionality. Hopefully isn't too hard to add, but the functionality here seems to need a test to go along with 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.
Looks good. A vscode test could be helpful here.
Codecov Report
@@ Coverage Diff @@
## main #4240 +/- ##
======================================
+ Coverage 71% 73% +2%
======================================
Files 384 384
Lines 25155 25206 +51
Branches 3598 3604 +6
======================================
+ Hits 17931 18561 +630
+ Misses 5826 5246 -580
- Partials 1398 1399 +1
|
test('Run cells above', async function () { | ||
// This test is skipped because there is no way of selecting a cell in this context | ||
// since by default the first cell is selected nothing happens when running all cells above | ||
this.skip(); |
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.
Looks good. I would just file the issue and then put the issue number here in the comment. That way when the test issue is resolved we know where to go to fix it. It's what we usually do for things like this.
nativeEditorCommandListener
For #4010
package-lock.json
has been regenerated by runningnpm install
(if dependencies have changed).