-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
Put the cursor at the merge point after merging two notebook cells #9671
Comments
I've just discovered a logical extension of my proposal: I was talking about merging cells, but one could also think about splitting cells. When splitting a cell, the second one of the two new cells has its cursor at the beginning of the cell. This totally makes sense. However, the cursor of the first cell is again reset to the beginning, while putting it at the end would be more consistent, because the end of the first cell was the "last edited" position. I think my original suggestion about merging is more important, but why not make splitting also consistent? |
FYI, the cursor position is totally managed by CodeMirror - as far as I know we do nothing about it. It happens to be saved in the edit cell because we maintain the CodeMirror editor. The cases where you see the cursor reset to the beginning is likely just because we create a new codemirror. I agree we could definitely do more to make the cursor management more sensible. Thanks for thinking through what sensible cursor management would look like! |
If you want to work on this, I think it probably would be fairly straightforward, though there may need to be some api additions to manage the cursor position, maybe? |
I'm sorry, but I really don't have the capacity to work on this right now. Also, I'm not very good at JavaScript and I don't want to become good either (because I hate it). I was hoping there are some other volunteers! Anyone? Is there some tag or something to make this more visible to potential contributors? In the meantime, I've found another situation with a minor quirk that could be improved: |
I understand and empathize with you on each of these points :).
If we could point out where in the codebase someone could start trying to make these changes (and presuming we already have the api to move the cursor), I think this would be a "good first issue"
Again, it's probably because we are replacing the cell with a different type of cell, and that probably involves creating a new CodeMirror, and the default is to start with the cursor at the top of the codemirror. |
Each cell seems to have a stored cursor position, which is restored whenever the cell is switched into "edit mode" by pressing the "Enter" key.
Problem
When merging two cells, the cursor position is reset to the beginning of the cell.
Proposed Solution
I think it would make more sense (if technically feasible), to set the cursor position to the merge point.
The cursor is normally at the "last edited" position, and the point between the two merged cell contents is logically the "last edited" position, isn't it?
I very often find myself wanting to delete an empty line between two merged Markdown cells, which would be much easier if the cursor would already be there.
Additional context
When multiple cells are merged at once, there are of course multiple merge points.
It seems that there is already a notion of a "last selected cell in a selection" (at least there is a marker in the user interface), which AFAICT is always either at the very top or the very bottom of the selection.
If that's true, it would of course make most sense to put the cursor between the "last selected" cell and the rest of 'em.
When clicking with the mouse into a code cell, the cursor is set to the mouse position, this should of course be unchanged, even after merging two code cells.
Apparently, the cursor position is not stored in the notebook file, and after loading a notebook, all cursor positions seem to be set to the beginning of the cell. This is totally fine. I don't expect the cursor positions to be stored.
The text was updated successfully, but these errors were encountered: