Skip to content
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

Associate information in the gutter with each folding point #45

Open
FALLAI-Denis opened this issue May 7, 2021 · 4 comments
Open

Associate information in the gutter with each folding point #45

FALLAI-Denis opened this issue May 7, 2021 · 4 comments
Labels
enhancement New feature or request

Comments

@FALLAI-Denis
Copy link

Describe the issue

With hierarchical folding (separator / separatorRegex + descendants), it becomes difficult to see the scope of a folding.

Would it be possible to materialize this scope visually at the level of VS Code?

  • Either by using particular folding markers, for example by using color codes (but I don't think that is possible).

  • Either by adding information in the gutter: a level number (which then makes it possible to use the commands Ctrl+K Ctrl+<niv>), or a colored line extending over all the lines concerned by the folding.

To reproduce

  • VSCode: 1.56.0
  • Explicit Folding: 0.11.0 (non official)
  • Language: COBOL
  • Language Provider: IBM Z Open Editor

Code Example

       IDENTIFICATION DIVISION.
       PROGRAM-ID. MYPROG.
       DATE-COMPILED.
       ENVIRONMENT DIVISION.
       CONFIGURATION SECTION.
       SOURCE-COMPUTER. IBM-370.
       OBJECT-COMPUTER. IBM-370.
       INPUT-OUTPUT SECTION.
       FILE-CONTROL.
           select DD-FICHIER assign to UT-S-DD.
      /
       DATA DIVISION.
       FILE SECTION.
       FD  DD-FICHIER
           block contains 0 records
           recording mode is F.
       01  ARECORD.
           05  R1      PIC X(10).
           05          PIC X(70).
       WORKING-STORAGE SECTION.  
       01  AGROUP.
           05  A1      PIC X(1).  
           05  A2      PIC X(5).
       01  ANOTHERGROUP.
           05  B1      PIC X(1).
           05  B2      PIC X(5).  
       LINKAGE SECTION.
       01  APARM.
           05          PIC X(10).
       PROCEDURE DIVISION using APARM.
       MAIN SECTION.
       START-OF-RUN.
           open output DD-FICHIER
           move "Hello World !" to ARECORD
           write ARECORD
           close DD-FICHIER
           .
       END-OF-RUN.
           goback.
       END PROGRAM MYPROG.

Settings

    "folding":
      {"cobol": [
         {// Division
          "separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?=\\s+(?i:DIVISION))"
         ,"strict": false
         ,"descendants": [
            {// Section
             "separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?=\\s+(?i:SECTION))"
            ,"strict": false
            ,"descendants": [
               {// Paragraph
                "separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?!\\s+(?i:SECTION|DIVISION))"
                ,"strict": false
                ,"descendants": [
                   {// Page eject
                    "separatorRegex":"(?<=^.{6})\\/"
                   }
                 ]
               }
             ]
            }
          ]
         }
       ]
      }

Expected behavior

See the scope of a folding before making it.

Screenshots

FoldingCobol2

@daiyam
Copy link
Member

daiyam commented May 7, 2021

The shortcuts Ctrl+K Ctrl+<niv> are already working fine.
The folding ranges are provided to VSCode as expected by it. There is no level in the spec, there are calculated by VSCode.
This extension will only provide folding ranges. Changing the visual behaviour would require another extension, if possible.

@FALLAI-Denis
Copy link
Author

My request was not about using the Ctrl+K Ctrl+<niv> commands which actually work well (although behaving confusingly).

My suggestion concerned the possibility of having visual feedback on the scope of a folding, for example by adding information in the gutter.
Something like what I tried to depict below:
ExplicitFolding-20210507-01

The formalism is just for illustration and could take a whole other form.

If VS Code does not manage a level in the folding, nor the "Explicit Folder" extension currently, perhaps it would be possible to associate an information with each declaration of markers in the "folding" settings, and that this information then be used for display in the gutter.
It would only be by pure convention that this information would be a level, it could also be any information.

The "Explicit Folder" extension could have a set of predefined icons, or give the possibility to provide your own icons, that we could associate with a group of markers, for display in the gutter.

For example by adding a "decoration" property to each group expressing a folding.
Which could give:

    "folding":
      {"cobol": [
         {// Division
          "separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?=\\s+(?i:DIVISION))"
         ,"strict": false
         ,"decoration": "icon01.png"
         ,"descendants": [
            {// Section
             "separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?=\\s+(?i:SECTION))"
            ,"strict": false
            ,"decoration": "icon02.png"
            ,"descendants": [
               {// Paragraph
                "separatorRegex": "(?<=^.{6}\\s{1,4})[A-Za-z0-9\\-_:]+(?!\\s+(?i:SECTION|DIVISION))"
                ,"strict": false
                ,"decoration": "icon03.png"
                ,"descendants": [
                   {// Page eject
                    "separatorRegex":"(?<=^.{6})\\/"
                   ,"decoration": "icon04.png"
                   }
                 ]
               }
             ]
            }
          ]
         }
       ]
      }

Confer DecorationRenderOptions.

@daiyam
Copy link
Member

daiyam commented May 7, 2021

I agree that it can be helpful.

VSCode manage the levels of folding since you can collapse the foldings based on their level.
But a folding range provider can't and doesn't need to provide it (VSCode can combine folding ranges from several providers. So a range from a provider can be a sublevel of a range from another provider).

Here the definition of a range:

class FoldingRange {
    start: number;
    end: number;
    kind?: FoldingRangeKind;
    constructor(start: number, end: number, kind?: FoldingRangeKind);
}

Me too, I would like to change how to display a folding, like adding the number of lines when the folding is collapsed.
If I had searched how to do it, it would have been the subject of another extension.

@FALLAI-Denis FALLAI-Denis changed the title Visually identify the scope of a folding Associate information in the gutter with each folding point May 8, 2021
@FALLAI-Denis
Copy link
Author

I modified my issue to no longer refer to a range, but just to associate visual information with each folding point.

I propose to leave this request pending and mark it as an "enhancement".

@daiyam daiyam added the enhancement New feature or request label Sep 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants