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

Ability to know if a custom view is visible or not #48198

Closed
patrys opened this issue Apr 19, 2018 · 14 comments
Closed

Ability to know if a custom view is visible or not #48198

patrys opened this issue Apr 19, 2018 · 14 comments
Assignees
Labels
feature-request Request for new features or functionality on-testplan tree-views Extension tree view issues
Milestone

Comments

@patrys
Copy link

patrys commented Apr 19, 2018

I maintain an extension that tries to have a tree view follow the cursor position in file in a similar fashion to how explorer pane follows the currently open document.

However when the tree view is collapsed or when a different sidebar pane is active VS Code will forcefully switch to the Explorer pane and expand the tree view. Users find it highly annoying, especially when trying to follow a stack trace in the debugger as clicking any stack frame focuses the code editor which in turn activates the extension and switched away from the Debugger to the Explorer pane.

The only option accepted by TreeView.reveal is select. I'd like to propose a focus option that controls whether the view should be brought to the front (ie. pane focused and tree view expanded) if it isn't there already.

@sandy081
Copy link
Member

I do not think focus will solve your problem. In fact it might worse. Because currently focus remains in the editor, with focus option you can control if to focus the view or not.

I think what you need to know is if the view is shown or not. Reveal it only if view is shown. Is it correct?

@sandy081 sandy081 added info-needed Issue requires more information from poster tree-views Extension tree view issues labels Apr 20, 2018
@patrys
Copy link
Author

patrys commented Apr 20, 2018

reveal() will currently make the view visible if it isn't. This means switch away from whatever the user was doing at the moment which is not always wanted.

@sandy081
Copy link
Member

Yes, reveal API as documented is to show the element to the user. So it is expected. But as I said you would like to decide when to call this or not.

@patrys
Copy link
Author

patrys commented Apr 20, 2018

I guess you could say so. My extension has no way to tell whether the view is currently visible or not. I want it to work the same way the explorer file tree does (ie. change selected element without forcing the explorer pane or the file tree view to be presented).

@sandy081
Copy link
Member

Yes, I agree that currently an extension cannot know if a view is visible or not. I would assume if you have that knowledge then this will fix your issue?

@patrys
Copy link
Author

patrys commented Apr 23, 2018

It would, yes.

@sandy081 sandy081 changed the title TreeView.reveal has no way to control focus Ability to know if a custom view is visible or not Apr 23, 2018
@sandy081 sandy081 added feature-request Request for new features or functionality and removed info-needed Issue requires more information from poster labels Apr 23, 2018
@sandy081 sandy081 added this to the Backlog milestone Apr 23, 2018
@DanTup
Copy link
Contributor

DanTup commented Apr 26, 2018

If we're going to skip selecting items when the view isn't visible, do we have the right events to ensure we can select the required item when the tree becomes shown? If not, would it be better to still allow us to select without making the view visible?

@sandy081
Copy link
Member

@DanTup This will let you know if the view is visible or not and then allow you to call reveal. I think it makes sense to have an event when a view is visible

@DanTup
Copy link
Contributor

DanTup commented Apr 26, 2018

Yeah, without the event, when the user first switches to the outline, it won't have any selection. It may need to fire after the tree has been rendered to ensure the nodes are all there so we can select?

@Gama11
Copy link
Contributor

Gama11 commented May 12, 2018

This behavior actually makes the reveal() API unsuitable to re-implement something along the lines of "explorer.autoReveal" in its current state. Imagine being in the search viewlet, and switching tabs forcefully changes back to the explorer viewlet to "reveal the file". Similar for forcefully reopening collapsed tree views. I can see how it might be useful that you can do this, but in most cases it's probably not desirable. :)

(for context: I originally suggested the API for that "re-implement explorer.autoReveal use case" in #30288)

@DanTup
Copy link
Contributor

DanTup commented May 29, 2018

@sandy081 I'm guessing it's not likely this would be done for v1.24? (not bumping, just trying to schedule merging a preview of something).

@sandy081
Copy link
Member

Mostly for 1.25

@DanTup
Copy link
Contributor

DanTup commented May 30, 2018

Ok, thanks!

@sandy081
Copy link
Member

sandy081 commented Jun 25, 2018

Tree view has now visible property and an event to listen on it.

/**
 * Event that is fired when the [selection](#TreeView.selection) has changed
 */
readonly onDidChangeSelection: Event<TreeViewSelectionChangeEvent<T>>;

/**
 * `true` if the [tree view](#TreeView) is visible otherwise `false`.
 */
readonly visible: boolean;
/**
 * The event that is fired when there is a change in [tree view's visibility](#TreeView.visible)
 */
export interface TreeViewVisibilityChangeEvent {

	/**
	 * `true` if the [tree view](#TreeView) is visible otherwise `false`.
	 */
	readonly visible: boolean;

}

@vscodebot vscodebot bot locked and limited conversation to collaborators Aug 9, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality on-testplan tree-views Extension tree view issues
Projects
None yet
Development

No branches or pull requests

4 participants