ONE-vscode
ONE-vscode copied to clipboard
[OneExplorer] Keep collapsing state of node
What?
Previously, when refresh
occurs due to a file's creation/change/deletion, all the tree nodes are built from scratch and the collapsing status resets.
By #1401, it's not building the whole tree but from the parent node. Let's try to keep the collapsing status of the node, now.
From
LGTM. Thank you for your effort!
Question: Isn't it possible to keep the Expand/Collapse of the model node in its original state after executing the 'Rename Model' command? It seems to be inconvenient to collapse unconditionally.
Originally posted by @lemmaa in https://github.com/Samsung/ONE-vscode/pull/1361#pullrequestreview-1147570225
Prerequisite
- [x] #1401
How?
Node node -> node.getTreeItem() -> OneNode oneNode
// oneNode.node === node
OneNode has a collapsible state
When refreshed, we need to pass 'initialCollapsibleState' from Node to OneNode, which must be disposed once it's used. Otherwise, the state will be applied everytime the node is re-builded.....
How? (2)
By using onDidRenameFiles
, we don't need to re-create all the Node&OneNode but just replace the url and the file name.
Then, the other contexts including collapsible state will be easy to keep
vscode.workspace.onDidRenameFiles((e)=>{
e.files.forEach(file=>{
console.log(file.oldUri, file.newUri);
});
}),
DID IT!
How?
- [x] Replace all the other apis from vscode.fs to vscode.workspace.applyEdit. Otherwise, the above change will triger other create/delete events again which makes unexpected refresh on the tree.
- #1437
- It's to use
onDidRenameFiles
api. It only works with vscode.workspace.applyEdit, not all the file system changes.
- [ ] Replace rename api from vscode.fs to vscode.workspace.applyEdit and event listener from fileSystemWatcher to vscode.workspace.onDidRenameFiles.
- [x] Add
id
to Node- #1438
-
id
is required to keep the same TreeItem, otherwise the tree view will generate a new TreeItem when the label(path) is different.
- [ ] Update the node's uri while persisting the Node using rename api.