fix: use correct target folder for createFolder/uploadFile in Workspace fs#1913
fix: use correct target folder for createFolder/uploadFile in Workspace fs#1913misha-db wants to merge 3 commits into
Conversation
…ce FS extension.ts Switches the Workspace FS panel registration from window.registerTreeDataProvider to window.createTreeView so the TreeView handle (which exposes selection) is available. The resulting workspaceFsTreeView is passed to WorkspaceFsCommands and disposed via context.subscriptions. WorkspaceFsCommands.ts - Accepts TreeView<WorkspaceFsEntity> as a new constructor parameter (private readonly treeView). - Tracks the last left-click–selected item in selectedElement via treeView.onDidChangeSelection (cleared to undefined on deselection). - In createFolder and uploadFile, resolves the target folder using a comparison: - If element !== treeView.selection[0] — the command was invoked from a context menu on a different item than the current selection → use element. - Otherwise — title bar button, or context menu on the already-selected item → use selectedElement (which is undefined if the user deselected before clicking, correctly falling back to the workspace root). This fixes two bugs: 1. Title bar click after deselection was targeting the previously selected folder instead of root. 2. Context-menu click on a non-selected item was targeting the selected folder instead of the right-clicked one.
|
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
|
Concern: this may not actually fix the reported bug (and the tests don't guard against it) I traced the logic and I think the core change is effectively a no-op. The key helper: private resolveTargetElement(element?) {
return element !== this.treeView.selection[0]
? element
: this.selectedElement;
}
So The tests pass against the original code too. I ran all 13 cases against the pre-PR logic ( Why I don't think the reported bug is addressed. The "title bar after deselection targets the previously selected folder" bug can only occur if, at title-bar-click time, the element/selection VSCode hands the command still points at the stale folder. But in that exact state Possible regression risk. The logic also relies on the assumption (stated in a test comment) that a right-click does not update Suggestion: before merging, could you verify the deselection repro empirically with vs. without this diff? If there's a real difference, it'd be worth pinning down exactly what VSCode passes for title-bar vs. context-menu invocations and adding a test that fails on the old code to prove the fix matters. If the intent is "title bar always creates at root, context menu uses the clicked item," distinguishing the two invocation paths explicitly (separate command IDs/args) would be more robust than reconciling |
Changes
Fixes title bar click after deselection was targeting the previously selected folder instead of root.
extension.tsSwitches the Workspace FS panel registration from window.registerTreeDataProvider to window.createTreeView so the TreeView handle (which exposes selection) is available. The resulting workspaceFsTreeView is passed to WorkspaceFsCommands and disposed via context.subscriptions.
WorkspaceFsCommands.tsTests
WorkspaceFsCommands.test.ts