Open ali80 opened 5 years ago
(Experimental duplicate detection) Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:
I want to add my support for this problem. It is particularly annoying when using the vim keybindings, as right after the fold is closed (using zc
), the mouse is above the just folded code, so if I want to move down below the folded region, it automatically unfolds as I do so.
As someone who uses the keyboard to navigate (vim plugin is a godsend) it's very frustrating that collapsed regions auto expand when I try to move past them. If the collapsed region is big I totally lose my place on the page.
@Frug you can set the vim.foldfix
setting to true
if you're using the vim plugin and it will fix this annoyance for you 😄️ (this works with simple movement but I'm not sure if it works with moving lines up and down, which is what this issue is about)
Any solution to the issue without an extension? I frequently use the alt up/down (editor.action.moveLinesUpAction / editor.action.moveLinesDownAction) shortcuts and this may be one of the most annoying counter-intuitive behaviors of VSC... Honestly, if you're moving a line of text (or a block), would anyone really want folded section to unfold? I mean, isn't the reason we are folding the section because we are not actively dealing with it?
Every time I try to use folding, I'm reminded how buggy and unintuitive it is and why I'd disabled folding altogether.
The feature needs a rework but I think it may have been abandoned, since this issue has now been open for +2 years.
I also need this feature.
BTW: I don't think it's possible to do this in a extension, since VSC doesn't seem to provide API to access the folded ranges. Unless you implement the folding feature all over again by yourself.
@Frug you can set the
vim.foldfix
setting totrue
if you're using the vim plugin and it will fix this annoyance for you 😄️ (this works with simple movement but I'm not sure if it works with moving lines up and down, which is what this issue is about)
Yes this is what I'm looking for. Thank you!
@Frug you can set the
vim.foldfix
setting totrue
if you're using the vim plugin and it will fix this annoyance for you 😄️ (this works with simple movement but I'm not sure if it works with moving lines up and down, which is what this issue is about)
I used vim.foldfix
but then when I try 10j
or 100k
I have a cursor delay due to the movement. I don´t know how to solve it.
I also need this feature.
BTW: I don't think it's possible to do this in a extension, since VSC doesn't seem to provide API to access the folded ranges. Unless you implement the folding feature all over again by yourself.
Through experimentation it seems that vscode.window.activeTextEditor.visibleRanges represents currently visible folded ranges, which one could use to know what to skip.
If someone with more knowledge can confirm this is accurate and there's no reason an extension couldn't use this info to know which ranges to skip when moving lines up and down I'd be happy to write it.
I'd love this to be resolved. It's not major but it is mighty frustrating, makes the feature of 'move line' much less powerful.
Did this functionality ever existing VSCode or am I remembering Sublime/Textmate?
I've had a look at the code starting from https://github.com/microsoft/vscode/blob/bc403a0b71f0013c7d3cdb2196e9acff32650095/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts#L43 and implementing this would require some major logic changes (the logic hasn't changed in 5-7 years) as currently it assumes only 1 line will have to move: https://github.com/microsoft/vscode/blob/bc403a0b71f0013c7d3cdb2196e9acff32650095/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts#L84 with the indentation checking/edits also making those assumptions https://github.com/microsoft/vscode/blob/bc403a0b71f0013c7d3cdb2196e9acff32650095/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts#L114-L115 https://github.com/microsoft/vscode/blob/bc403a0b71f0013c7d3cdb2196e9acff32650095/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts#L297-L300
An implementation question would also be how to add checking whether a line belongs to a fold.
inline-folded
but its not the proper way and folds could be 1 line long (region) or two lines (brackets)ServicesAccessor
and use it to get the ICodeEditor
, then use FoldingController
to get the FoldingModel
and call getRegionAtLine
but getFoldingModel
is a Promise and then you'd have to wrap the rest of the function in a .then()
block
https://github.com/microsoft/vscode/blob/bc403a0b71f0013c7d3cdb2196e9acff32650095/src/vs/editor/contrib/folding/browser/folding.ts#L89
FoldingController
to return FoldingModel
without updating it? Could cause bugs I assume.Once you have the folding ranges you could then update the logic from "Move 1 line" to "Move n lines".
@aeschli I also noticed that moving down and up don't actually perform the same logic.
So moving the statement down
and moving the bracket up
should theoretically be the same but results in different edits. Is this a bug or intended behaviour?
Related on Stack Overflow: How can I move lines or folded regions before or after other folded regions?.
Atom Editor had the feature out of the box... -.- -.- -.-
You could move an entire folded region up and down through other collapsed regions with the same single move up and down command...
Can't anyone on VSCode teams just take the code from Atom and adapt it fo Vscode?
It's really frustrating...
I think when code is in a folded region or section it should never unfold unless explicitly commanded, so if you are moving a line using move command, the line should skip over both folded regions and folded sections Steps to Reproduce:
Does this issue occur when all extensions are disabled?: Yes