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
[folding] Move line up/down should skip over folded regions or folded sections #63972
Comments
(Experimental duplicate detection) |
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 |
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 |
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. |
Yes this is what I'm looking for. Thank you! |
I used |
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
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:
with the indentation checking/edits also making those assumptions vscode/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts Lines 114 to 115 in bc403a0
vscode/src/vs/editor/contrib/linesOperations/browser/moveLinesCommand.ts Lines 297 to 300 in bc403a0
An implementation question would also be how to add checking whether a line belongs to a fold.
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.
Code_81taQdj4r6.mp4So |
Related on Stack Overflow: How can I move lines or folded regions before or after other folded regions?. |
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
The text was updated successfully, but these errors were encountered: