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

[folding] Show number of lines folded #130250

Open
uber6 opened this issue Aug 6, 2021 · 13 comments
Open

[folding] Show number of lines folded #130250

uber6 opened this issue Aug 6, 2021 · 13 comments
Assignees
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Milestone

Comments

@uber6
Copy link

uber6 commented Aug 6, 2021

Current when a block is folded it currently only show ellipses, which I think it could be improved by show the lines of code in the block.

e.g. (using Python as an example)

def printthis(printme):
    print(printme)
    print("how did it print?")

When the code above is folded, it is represented as:

def printthis(printme): ...

Instead of just "...", it would be very useful to display how many lines are folded.

def printthis(printme): ...(2 lines)...

With short block it is not too difficult to identify the number lines folded by looking at the line number, but for a larger blocks, it would aid significantly by showing the number of line folded.

@uber6
Copy link
Author

uber6 commented Aug 6, 2021

Thanks bot, but none of the recommendations are like mine.

@NathanielRN
Copy link

Also related: #124177

@aeschli aeschli added editor-folding Editor code folding issues feature-request Request for new features or functionality labels Aug 18, 2021
@aeschli aeschli added this to the Backlog Candidates milestone Aug 18, 2021
@NathanielRN
Copy link

Instead of just "...", it would be very useful to display how many lines are folded.

Just a small suggestion now that we hit the votes 🙂 Instead of "number of lines", I think it would be great if it said "number of items".

For example:

"CloudWatchMetrics": [
    {
        "Namespace": "test",
        "Dimensions": [
            [
                "process.pid",
                "process.executable.name",
                "process.executable.path",
                "process.command",
                "process.command_line"
            ]
        ],
        "Metrics": [
            {
                "Name": "process.memory.physical_usage",
                "Unit": "Bytes"
            },
            {
                "Name": "process.memory.virtual_usage",
                "Unit": "Bytes"
            }
        ]
    }
],

would become

"CloudWatchMetrics": [
    { ...(1 item)...
    }
],

Especially since you can already see the # of lines in the sidebar:

image

@aeschli aeschli added the help wanted Issues identified as good community contribution opportunities label Aug 19, 2021
@aeschli aeschli changed the title Show number of lines folded [folding] Show number of lines folded Aug 19, 2021
@lifez
Copy link
Contributor

lifez commented Aug 21, 2021

@aeschli Can I start on this issue?

@barisunsalhn
Copy link

@aeschli I think this issue is better suited for an extension. What do you think?

@aeschli
Copy link
Contributor

aeschli commented Sep 13, 2021

I don't think this can be done in an extension as there's no API to access all folded regions.
The change would be in the core.
Check out https://github.com/microsoft/vscode/tree/main/src/vs/editor/contrib/folding
The inline-folded is the css class that adds the ....

@iKlsR
Copy link

iKlsR commented Oct 15, 2021

This would be very useful, after using it in the insomnia client can't imagine not having it before.
test

@jzyrobert
Copy link
Contributor

So I remembered I had given this a go a while ago, except it didn't work properly:
image

The decoration wouldn't update in real-time until you edited the document, and it would randomly freeze VS Code when you clicked fold/unfold too often. But if someone wants to pick it up, my WIP code changes are in this commit: 67c4de2

@tomputer-g
Copy link

Giving this a try.

@tomputer-g
Copy link

Hmm, @jzyrobert 's WIP commit doesn't seem to want to work (at least, on my end) when I apply the contents to a new fork from December of main branch. The decoration gets created just fine but changeDecorationOptions doesn't apply the inline-folded-count element (the thing that includes the injected text for the lines).

Also, sometimes removing sections of content between brackets or close then reopening a file crashes the editor very badly... I'll look into these issues some more in a few days but anyone please feel free to work on this as well.

@mtbaqer
Copy link

mtbaqer commented Jan 23, 2023

Hey everyone, I managed to make an extension that solves this problem along with other many requested folding-related issues. You can find it here:

https://marketplace.visualstudio.com/items?itemName=MohammadBaqer.better-folding

A demo of the extension in action:

Screen.Recording.2023-01-23.at.12.14.58.mov

@zorapeteri
Copy link

zorapeteri commented Jun 25, 2023

I've wanted to comment this on #124177 but since it's closed and this issue is mentioned on it I'm sharing here:

in case anyone needs this for viewing JSON files in vscode and wants to see how many keys there are in an object (like with codemirror/insomnia):
I've found an extension that albeit doesn't show the numbers in the editor itself, it does show you how many keys objects have and some other cool stuff, without having to leave vscode.

https://marketplace.visualstudio.com/items?itemName=ZainChen.json

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

11 participants