microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
163.7k stars 29.07k forks source link

Editor feature that spans multiple cells #141673

Open eteq opened 2 years ago

eteq commented 2 years ago

Right now if I do an alt-click (or ctrl-d) in the notebook extension it behaves just like the regular editor within a single cell. However, my workflow often involves using multi-select throughout a notebook because I have the same variable/whatever repeated in multiple cells near each other, but not in the same cell. It would be extremely useful if there was a way to make multi-cursor selections span multiple cells.

In fact, my work flow right now is to open a notebook in text only mode and use multi-select there with the jupyterlab interface open in a browser window. With this feature implemented I could dispense with the headaches of saving and reloading there and have it all in one vscode interface.

IanMatthewHuff commented 2 years ago

Thanks for the suggestion. That does sound like a handy feature. Right now each cell is (as you noticed) treated as a separate editor.

greazer commented 2 years ago

Supporting this across cells is a core Code issue to solve.

vscodenpa commented 2 years ago

This feature request is now a candidate for our backlog. The community has 60 days to upvote the issue. If it receives 20 upvotes we will move it to our backlog. If not, we will close it. To learn more about how we handle feature requests, please see our documentation.

Happy Coding!

cipri-tom commented 7 months ago

@Yoyokrazy do you think this would be included in the backlog at some point ? I think it's important but super difficult to search for it ; took me multiple tries and I almost opened a new one. So it's very tough for other people to find and upvote.

Without this feature, there is no useful "Refactor" feature. When I try Refactor, it says there are no refactorings available. Whereas I'd like to at least be able to change the name of a function / variable.

Edit: it seems interesting that the Python extension can correctly identify tokens across cells, since it underlines in yellow occurences of a function after I rename it in a different cell.

image

Cheers !

Yoyokrazy commented 2 months ago

Updates from an initial exploration into this:

cc/ @rebornix Basic work has been done to explore this concept of multiple selections across multiple cells. Initially there was thought surrounding alt-click multi-cursor implementation, however a number of unknowns will make that an increasingly complex issue to solve. The standard monaco editor performs hit tests and detection to properly place secondary cursors, and the logic to implement that in a notebook editor with a number of editors in a list view would be overly complex to begin with.

The initial work has gone with the approach of creating a cmd+d multiselect action that overrides the standard code editor action. This action will only be enabled with a tight when clause, and allow the user to find and select multiple occurrences throughout multiple cells of the notebook.


More thoughts, but bulleted:


Todo tasks: