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] Allow to specify if decorator should hide in collapsed region #4812

Closed
alefragnani opened this issue Mar 31, 2016 · 12 comments
Closed
Assignees
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality
Milestone

Comments

@alefragnani
Copy link

When you define decorators for an editor (activeEditor.setDecorations), you must define a Range, which can be a specific line where you want to add that decorator (an image with gutterIconPath for instance).

But if you Fold the lines where this decorator is defined, the icon is not hidden with the lines, but instead, it is shown in the line where the folding starts.

I didn't find anything in line or decorators that could be used to detect if the line is folded, so I think that the folding engine should be taking care of that, right?

Thanks in advance

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug editor-folding Editor code folding issues labels Mar 31, 2016
@aeschli aeschli closed this as completed Mar 31, 2016
@aeschli aeschli changed the title Code Folding is not hidding the Decorators attached to lines [folding] Code Folding is not hidding the Decorators attached to lines Mar 31, 2016
@aeschli
Copy link
Contributor

aeschli commented Mar 31, 2016

@alefragnani If you could add also a code snippet that would be great. That way I can use this as test once we add language agnostic folding.
Thanks a lot!

@alefragnani
Copy link
Author

Hi @aeschli , I will post a code snippet latter, when I go back to my home 😄 , but in the meantime you could see the same behavior using breakpoints.

If you set a breakpoint inside a function and fold the entire function, the breakpoint is presented in the folding line.

If that is the expected behavior, than it's ok... I just thought it should suppress the icon.

Thanks

@alefragnani
Copy link
Author

Hi @aeschli ,

The code is fairly simple. I just create a TextEditorDecorationType and assign it to the vscode.window.activeTextEditor with an array of Range, which each element defines a line in the text.

  • Creating the decoration
    var bookmarkDecorationType = vscode.window.createTextEditorDecorationType({
        gutterIconPath: pathIcon,
        overviewRulerLane: vscode.OverviewRulerLane.Full,
        overviewRulerColor: 'rgba(21, 126, 251, 0.7)'
    });
  • Defining the lines that will show the decoration. Each activeBookmark.bookmarks element is a number that represents a line number in the text
        var books: vscode.Range[] = [];
        for (var index = 0; index < activeBookmark.bookmarks.length; index++) {
            var element = activeBookmark.bookmarks[index];
            var decoration = new vscode.Range(element, 0, element, 0);
            books.push(decoration);
        }
  • Adds the set of decorations to the activeTextEditor
    vscode.window.activeTextEditor.setDecorations(bookmarkDecorationType, books);

As you can see, the decoration is defined to individual lines, to display the icon in the Gutter (like breakpoints). But then, when the code is folded, the icon is shown in the folding line. Take a look at the GIF below.

bookmarks-folding

Thanks for your help

@aeschli
Copy link
Contributor

aeschli commented Apr 1, 2016

@alefragnani Ah, now I understand. Ignore my first comment (I removed it).
There's no API for you to find out if a line is visible or not. We actually try to avoid that.
Would it make sense that you could specify if your annotation should hide for a folded region?
@alexandrudima Alex, FYI.

@aeschli aeschli reopened this Apr 1, 2016
@aeschli aeschli added this to the Backlog milestone Apr 1, 2016
@alefragnani
Copy link
Author

@aeschli No problem. In fact it was my fault, because I should have added this GIF right in the first post 😄

About your suggestion, I totally agree 👍 .

Thanks again

@aeschli aeschli changed the title [folding] Code Folding is not hidding the Decorators attached to lines [folding] Allow to specify if decorator should hide in collapsed region Feb 28, 2017
@aeschli aeschli added feature-request Request for new features or functionality and removed bug Issue identified by VS Code Team member as probable bug labels Feb 28, 2017
@aeschli aeschli modified the milestones: May 2017, Backlog May 3, 2017
@aeschli aeschli closed this as completed in b4afac4 May 3, 2017
@aeschli
Copy link
Contributor

aeschli commented May 18, 2017

For the May release I added a new setting so that the fold controls stay always visible:
"editor.showFoldingControls": "always"

@notrealdev
Copy link

Hi @aeschli , fold controls avaiable on version 1.12.1 ??
"editor.showFoldingControls": "always"

@aeschli
Copy link
Contributor

aeschli commented May 19, 2017

It will be in 1.13

@aeschli aeschli added verification-needed Verification of issue is requested and removed verification-needed Verification of issue is requested labels May 30, 2017
@aeschli aeschli modified the milestones: Backlog, May 2017 Jun 1, 2017
@aeschli
Copy link
Contributor

aeschli commented Jun 1, 2017

Sorry, I closed the wrong issue.

@aeschli aeschli reopened this Jun 1, 2017
@martin77s
Copy link

"editor.showFoldingControls": "always"
stopped working in 1.17

@aeschli
Copy link
Contributor

aeschli commented Oct 9, 2017

Thanks @martin77s, I created #35885

@aeschli
Copy link
Contributor

aeschli commented Nov 22, 2017

Since 1.18, decorations inside folded regions are hidden for performance reasons. They are no longer shown in the gutter.
There are no plans to make this configurable.

@aeschli aeschli closed this as completed Nov 22, 2017
@vscodebot vscodebot bot locked and limited conversation to collaborators Jan 6, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-folding Editor code folding issues feature-request Request for new features or functionality
Projects
None yet
Development

No branches or pull requests

5 participants