redhat-developer / vscode-yaml

YAML support for VS Code with built-in kubernetes syntax support
MIT License
644 stars 218 forks source link

Fold all by label #931

Open ChrisWeiss opened 1 year ago

ChrisWeiss commented 1 year ago

Is your enhancement related to a problem? Please describe.

As someone who works with Ansible and makes frequent use of inline Vault-encoded secrets, I often have large chunks of text in my code that are gibberish and I dont need to directly edit. IE:

    -name : "my_web_cert"
     data: !vault |
        $ANSIBLEVAULT;1.1:AES256
        29387345782436495734589632895763298756238576234987652384756239854623987568395642
        [repeat for many lines]
        45i35928375483975

Describe the solution you would like

As VSCode (and the YAML extension) support code-folding based on indentation/nodes, it would be quite helpful to be able to fold all nodes matching a specific text-string (maybe all nodes that match the currently highlighted text) so I could, for example, fold all the data: !vault | content with one quick action.

Describe alternatives you have considered

Would it be better to add this functionality to VSCode's core and make it a general feature across all code? Possibly. I'm not sure what the impacts of using it on non-'structured' would have. This is just my specific use case. I will add a similar request to the core VSCode project for discussion.

Additional context

gorkem commented 1 year ago

It sounds like this is a request to enable folding for multiple strings. Does that sound right?

ChrisWeiss commented 1 year ago

I don't think that's what I am talking about.

It would be for folding (or unfolding) multiple blocks that start with (or maybe even just contain?) matching strings with a single command.

For instance, I'm editing a C file that's got IFDEF macros sprinkled throughout. I might want to fold all #IFDEF SPECIFIC_MACRO_I_DONT_CARE_ABOUT blocks in the loaded file at once just to make visually parsing the file easier.

This file (not mine) is an excellent example of why I'd want to easily fold all blocks that start with with ssh_key_data !vault (or better yet, just blocks that start with a line that contains just !vault)