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

Hide "XML Document" Tree View for Non-XML Documents #104

Closed
ionut-botizan opened this issue Jun 16, 2017 · 11 comments
Closed

Hide "XML Document" Tree View for Non-XML Documents #104

ionut-botizan opened this issue Jun 16, 2017 · 11 comments

Comments

@ionut-botizan
Copy link

Like the title says, you should only display the explorer tree view when a user opens a XML document. It's a waste of space having it there all the time.
Not sure about it, but I believe this could be achieved using the onLanguage activation event:
https://code.visualstudio.com/docs/extensionAPI/activation-events

@DotJoshJohnson
Copy link
Owner

There is currently no official API available to turn the custom view on and off, but I'll play around with it to see if I can make something work. While an event is raised by VS Code when the user "activates" the view, it is a "one-way" street. I can only listen to the event to know when a user opens the view, I can't raise an event to close the view.

I'll do a little research on this and submit an issue to the main VS Code repo if needed.

@Danieleeee
Copy link

Danieleeee commented Jun 16, 2017

Hi @DotJoshJohnson ,
you can activate this extension only under xml language.
In package.json:

"activationEvents": [
        "onLanguage:xml"
    ],
"contributes": {
        "languages": [{
            "id": "xml",
            "aliases": [
                "XML",
                "xml"
            ],
            "extensions": [
                ".xml"
            ]
        }],
 "grammars": [{
            "language": "xml"
        }],

So we avoid triggering the extension with unsupported programming languages ​​and consequently saving resources

@DotJoshJohnson
Copy link
Owner

@Danieleeee - Extension activation is handled in the activationEvents property. I already only activate the extension on a supported language or when a command from this extension is invoked (see https://github.com/DotJoshJohnson/vscode-xml/blob/master/package.json#L124-L132). The issue is, I cannot "deactivate" the extension once it is activated.

@Danieleeee
Copy link

There is also the problem that the extension, or at least the tree view, is opened at vscode startup:
schermata 2017-06-16 alle 18 37 53
Does not mean the file type you opened

@DotJoshJohnson DotJoshJohnson changed the title Only display the explorer tree view when a XML document is opened Hide "XML Document" Tree View when for Non-XML Documents Jun 16, 2017
@DotJoshJohnson
Copy link
Owner

@Danieleeee - Right, but as I said, I don't seem to have any control over when the custom view is turned on and off.

It looks like the ability to toggle custom views is being worked on (per microsoft/vscode#27823). I'll keep an eye on the progression of these APIs. Custom views is a new feature, so I'm sure we'll see plenty of movement in this space in the coming weeks/months.

@DotJoshJohnson DotJoshJohnson changed the title Hide "XML Document" Tree View when for Non-XML Documents Hide "XML Document" Tree View for Non-XML Documents Jun 16, 2017
@Danieleeee
Copy link

Ok, thanks

@Silvenga
Copy link

Silvenga commented Jul 12, 2017

@DotJoshJohnson taking a look at the issue you linked, the ability to selectively hide has been merged:

It's implmented like these:
https://github.com/Microsoft/vscode-extension-samples/blob/master/tree-view-sample/package.json#L30
https://github.com/eamodio/vscode-gitlens/blob/master/package.json#L1519

Looks like it a part of this release: microsoft/vscode#28387

I can write a pull if you want. 😸

@DotJoshJohnson
Copy link
Owner

@Silvenga - Thanks for the heads up! If you want to submit a PR, I'll be more than happy to merge it in. Otherwise, I'll have time Sunday or Monday to make the change.

@DotJoshJohnson DotJoshJohnson added this to the 2018-MAR milestone Mar 2, 2018
@Yanpas
Copy link

Yanpas commented Mar 11, 2018

I don't need it even in xml docs, hope to see config that disables it

@DotJoshJohnson
Copy link
Owner

This will be taken care of in the v2 release.

@DotJoshJohnson DotJoshJohnson removed their assignment Apr 29, 2018
@DotJoshJohnson
Copy link
Owner

Released in v2.0.0-preview.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants