Skip to content
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

Pressing "End" when selecting multiplle cells does not expand selection #6783

Closed
krassowski opened this issue Jul 8, 2019 · 2 comments
Closed
Labels
enhancement good first issue pkg:notebook status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Milestone

Comments

@krassowski
Copy link
Member

When navigating notebook Up an Down arrows move us one cell up or down; pressing Home or End quickly scrolls up to the beginning or end of the notebokok.

If we select cells in a notebook, we can extend the selection down with Shift + Down or reduce it with Shift + Up (and vice versa when going up from the starting cell).

However, Shift + End does not select all the cells until the end of the notebook (and Shift + Home does not select cells till the begining).

Expected behavior
I would expect the Shift + Home/End to select all cell in specified direction, just as if I were repeating Shift + Up/Down until reaching the begining/end of he notebook.

Desktop (please complete the following information):

  • OS: Ubuntu 19.04
  • Browser: Chrome 70+
  • JupyterLab: 1.0.1
@krassowski krassowski changed the title Pressing "End" when selecting multiplle cells does not select expand selection Pressing "End" when selecting multiplle cells does not expand selection Jul 8, 2019
@ian-r-rose
Copy link
Member

I think this is a nice idea @krassowski (though I would expect this behavior on PageUp and PageDown, rather than Home and End, which is how my text editor behaves).

I think this would be a good issue for an advanced new contributor.
One would add new commands to the command registry to select all above/below, mimicking these commands:

commands.addCommand(CommandIDs.extendAbove, {
label: 'Extend Selection Above',
execute: args => {
const current = getCurrent(args);
if (current) {
return NotebookActions.extendSelectionAbove(current.content);
}
},
isEnabled
});
commands.addCommand(CommandIDs.extendBelow, {
label: 'Extend Selection Below',
execute: args => {
const current = getCurrent(args);
if (current) {
return NotebookActions.extendSelectionBelow(current.content);
}
},
isEnabled
});

The notebook actions extendSelectionAbove and extendSelectionBelow could be enhanced to take an option for whether to extend just one cell, multiple cells, or to the top/bottom:

/**
* Extend the selection to the cell above.
*
* @param notebook - The target notebook widget.
*
* #### Notes
* This is a no-op if the first cell is the active cell.
* The new cell will be activated.
*/
export function extendSelectionAbove(notebook: Notebook): void {
if (!notebook.model || !notebook.activeCell) {
return;
}
// Do not wrap around.
if (notebook.activeCellIndex === 0) {
return;
}
const state = Private.getState(notebook);
notebook.mode = 'command';
notebook.extendContiguousSelectionTo(notebook.activeCellIndex - 1);
Private.handleState(notebook, state, true);
}
/**
* Extend the selection to the cell below.
*
* @param notebook - The target notebook widget.
*
* #### Notes
* This is a no-op if the last cell is the active cell.
* The new cell will be activated.
*/
export function extendSelectionBelow(notebook: Notebook): void {
if (!notebook.model || !notebook.activeCell) {
return;
}
// Do not wrap around.
if (notebook.activeCellIndex === notebook.widgets.length - 1) {
return;
}
const state = Private.getState(notebook);
notebook.mode = 'command';
notebook.extendContiguousSelectionTo(notebook.activeCellIndex + 1);
Private.handleState(notebook, state, true);
}

Then one would add a keyboard shortcut that checks for the up/down arrows and pageup/pagedown/home/end:

{
"command": "notebook:extend-marked-cells-above",
"keys": ["Shift ArrowUp"],
"selector": ".jp-Notebook:focus"
},
{
"command": "notebook:extend-marked-cells-above",
"keys": ["Shift K"],
"selector": ".jp-Notebook:focus"
},
{
"command": "notebook:extend-marked-cells-below",
"keys": ["Shift ArrowDown"],
"selector": ".jp-Notebook:focus"
},
{
"command": "notebook:extend-marked-cells-below",
"keys": ["Shift J"],
"selector": ".jp-Notebook:focus"
},

@jasongrout
Copy link
Contributor

Fixed in #7177

@jasongrout jasongrout added this to the 2.0 milestone Oct 12, 2019
@lock lock bot added the status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion. label Nov 11, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Nov 11, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement good first issue pkg:notebook status:resolved-locked Closed issues are locked after 30 days inactivity. Please open a new issue for related discussion.
Projects
None yet
Development

No branches or pull requests

3 participants