-
Notifications
You must be signed in to change notification settings - Fork 29.9k
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
Feature request: API for managing folding area #9786
Comments
Discussed with Sandeep. The goal is provide commands that let you implement the VIM requirements. Unless really needed, we try not to introduce the concept of the folding regions in the extension host API. |
@aeschli I'm Okay with hiding folding region info. If we can provide generic API to navigate/manage folding regions, then it would be perfect. If it turns out that we are adding too many Vim specific commands, maybe it can be a good time to introduce Fold. |
There are already existing commands supporting some folding functionalities / operations. So, we can add more if necessary or needed. True that we are adding them as Vim needs them, but we are making sure that they are generic enough for any extension to use. |
@aeschli
I don't understand what's the reason behind your decision to hide these information from extensions. I get the feel that you trying to do the extension writer jobs. If you provide the basic info for folding regions then extension writers can implement anything on top of it.
I think wrapping folding info with generic enough apis is not realistic right now. Having information on folding areas gives extension writers more power on how to control the editor. we can easily implement |
Vim allows us to create Fold area manually, by indentation, expression or syntax while Code is doing foding by indentation. But customizing the folding creation is not frequently used by Vim users so we should go with indentation first. The first part is not folding command directly but they rely on folding info
The second part is openning/closing folds and they only require fold information.
The third part depends on option foldlevel. 'foldlevel' is a number option: The higher the more folded regions are open.
Others are folding area manual creation/deletion and Fold options but I don't think we need to take them into consideration before we handle all commands above. |
Exposing folding regions (or any view regions) to the extensions is not helpful because they are based on internals. It will make difficult for extension developers to implement on top of them correctly. Instead, developing and exposing the commands will make it available to everybody and easier to use. I agree that it is not possible to develop commands / api that can meet everyone's requirements. Since it is an open community, it is always welcome to discuss/request/contribute them. Again, just exposing folding regions will not be enough to implement commands like |
With great power comes great responsibility!
I don't think querying the export class IndentRange {
_indentRangeBrand: void;
startLineNumber:number;
endLineNumber:number;
indent:number;
....
} Better yet just replace
If you take the route of implementing apis with vim extensions in mind then you are doing the extension writers job, we will have future issues opening on vscode instead of the relative vim plugin repository. That being said the commands @rebornix listed is all that i've ever used in vim and i think that's true for many many vim users and those who have used more than that will never switch from the original vim 😄 |
@aminroosta Agreed that exposing just folding ranges is nothing to do with the internals. But, to implement the folding commands (navigation or toggling), this data is not going to be enough and you need internal details. I think exposing commands is the right approach for the above listed commands. |
After discussing with @rebornix, Creating / Deleting foldings will not be supported because
Unless it is really required for Vim, we will de-scope it. |
@sandy081 @rebornix All off the commands rebornix listed can be implemented. I can't think of any command from first and second part of commands that rebornix listed that can't be implemented with just this info. If you allow adding and removing to and from fold list then the third part can be implemented as well. |
@rebornix I enhanced |
Sure I'll give it a try real quick. |
@sandy081 I've tried your new args but it doesn't work. But I don't think it's your code's problem as |
I noticed folding doesn't work in TypeScript but works in JavaScript. But I'm not seeing it take effect. For example,
if we run
However, if I run
It's the same as |
So in the above example, this folds only one level at line 3 because there are no sub foldings under it. Let me know if I there is some mis-understanding of the documentation. |
@sandy081 ha that makes sense. |
@rebornix So the current behavior of |
@sandy081 I tested it again but found that My repro steps are : run |
@rebornix See the attached video, it works as expected for me First, I folded 2 levels by |
@sandy081 thanks for the video, it addresses the behavior well and now it's working on my machine perfectly as well! |
@sandy081 Now that you are working on folding APIs please also take a look at folding end This is really deal breaker to me, every other text editor (except sublime) does it right. Don't make us wait another month ;-) |
@aminroosta We are already in end game, so I am afraid we can push any major changes. But, I will take a look and see if they are small enough to make it. Thanks |
Structural/Scope based code folding was a feature I implemented for VisualFSharpPowertools and one I'd love to bring over to Ionide-FSharp The current indentation and brace based approach does a pretty good job, but it's unable to accurately capture the scopes of some of F#'s constructs and doesn't always use the same bounds for the folded region as the lexicographic scope. The other advantage a folding API would provide us is the ability to filter which constructs are folding enabled |
@aminroosta There were not any plans for now to implement this. This need a strong use case and discussion from language protocol perspective since foldings can be language specific too. |
This feature request will not be considered in the next 6-12 months roadmap and as such will be closed to keep the number of issues we have to maintain actionable. Thanks for understanding and happy coding! |
We are adding commands for fold/unfolding code in Vim and it turns out that Code's APIs are somewhat limited. All Vim's folding commands can be categorized as below.
Close/Open Folds (Done)
Vim allows users to open/close folds under cursor. Users can also decide how deep the folds are opened or closed.
These commands are partially supported, we have
editor.fold
,editor.unfold
,editor.foldRecursively
, etc and it's easy to map them to Vim commands. Besides, Code supports us tofold
from level 1 to level 5 but level 6 and above is not supported and we don't have similar commands forunfold
.Vim even supports us to toggle Fold. We don't have this command in Code and we can't use
editor.fold
oreditor.unfold
to workaround as we have no idea whether we are inside a folding area.Fold creation/deletion
Vim allows users to create or delete folds manually. It's not possible here as Code is doing this for us.
Navigate through Folds
We can navigate to previous or next fold area through commands in Vim. If we want to implement this in Code, we need to know the info about all folds.
Fold options
We can configure max/min screen lines for a fold, max level for folds, etc in Vim. Again, we didn't expose them in Code.
There are about 20+ unique commands and 10+ options about folding and we can only implement 5 of them partially right now.
The text was updated successfully, but these errors were encountered: