-
Notifications
You must be signed in to change notification settings - Fork 30.1k
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
Allow programatically un-selecting an item in a contributed tree #48754
Comments
@sandy081 If this isn't possible yet, do you know of any workarounds? I'm trying to keep a node selected based on where the user is, but I need to unselect it when they navigate somewhere I don't have a node for (it's really confusing to leave the last thing selected). |
See #1180. Blocked on microsoft/vscode#48754 though, because the selected node stays selected even when you move to another file.
@DanTup Sorry, there is no workaround. I will try to implement this soon. |
See #1180. Blocked on microsoft/vscode#48754 though, because the selected node stays selected even when you move to another file.
@sandy081 Is this still planned? |
@DanTup not for January. |
@sandy081 Any chance for Feb? :) |
No tree features planned in Feb. Would be jumping back to them in March for sure. |
@sandy081 I don't suppose this might happen soon? I've almost gotten my Outline to a state that I'd be comfortable shipping, but it still has some rough edges like this one. |
Not this milestone, but will bring this up in next. |
Thanks! 👍 |
Any news? (sorry for all the pings, catching up on snoozed emails 😃) |
Adding @alexr00 |
@alexr00 this request is to be able to do it programatically. Eg. to highlight a tree item relevant to where the current cursor position is (eg. in a test that's rendered in the tree), and then unselect it when the cursor is moved to a location where no nodes would be selected. |
Given this isn't a feature end users see directly (it depends very much on what extensions build on it), this seems somewhat unlikely. Not doing it prevents extension authors from building certain features (for example tracking the selected test as you move around, just like the built-in Outline view does) (I can encourage my users to come and 👍 this, though I don't know if that's spammy or frowned upon - it doesn't seem like a natural way of gauging interest) |
🤷♂️ |
@alexr00 @sandy081 should we expect that this will never be implemented? 😞 There are even built-in VS Code trees that behave strangely because of it. For example, the explorer tree follows around the current active file - yet if you open a file not in the tree (for example a new file), it just remains on the last selection. |
@DanTup I can see why API for this would be useful, but given that only one person wants this API it's reasonable to expect that very few people would use the API. It's hard for me to justify the time required to add the API. So yes, unless we see more support for such an API, then we probably won't implement it. |
Only one extension author wanting an API isn't necessarily the same as only one person would benefit from this API. Users don't necessarily know what APIs are required for which features. I could encourage users that want a feature that relies on this to come and 👍 this issue, but that feels a bit spammy/gaming the system. Would that be the best way to help guage interest? I also gave an example of where VS Code itself could benefit from this API - its explorer keeps the "last" file focused when you open a new one that isn't in the tree, which seems unintentional and would need this API to fix. |
Re-opening to gauge further interest. |
I encountered a similar issue where I needed to clear my selection, but unfortunately, it seemed impossible. Despite my efforts to find a solution, I was unable to come up with a workaround and ultimately had no success. |
FYI in case it helps: #174811 (comment) |
I would like to use this feature in my extension. |
Any results on this one? I just wanna to have the same flow as we have inside Files Explorer => When we click on a file -> It opens. And even when the selection on this file is still present in Files Explorer you can reopen the file without any problems. With the current implementation of TreeView such flow is impossible to achieve |
FWIW I'd also be interested in such an API or at least have a workaround to achieve more or less the same |
ditto |
Need the same feature in my extension. |
I need this as well. If we could either deselect or at least clear the selection that would solve the use case for me. |
I don't understand the resistance to make a standard tree component behave like a standard tree component that would exist in every other framework. A selection-based tree component is a standard type of component that I think most developers will expect and need the standard behaviors. Just my 2 cents, |
Yes, this would be useful. |
We can select items in the tree node with
reveal
, but we can't un-select. For an outline view that follows the users cursor, it would be good to unselect when the user moves the cursor to some empty whitespace that doesn't have a matching node.The existing explorer treeview also does this; if you open a file that's outside of the workspace folders (or create a new untitled file) then no items are selected in the tree.
The text was updated successfully, but these errors were encountered: