Skip to content

Second delete folder operation does not work in Insiders 1.41.0 #85938

Closed

Description

Hei!👋

Found issue with folder delete operation. The point is, when you delete folder (first time), no matter how, via mouse or keyboard combination, then select another folder and try to delete it, you will get popup message saying "Cannot read property 'isDirectory' of undefined"🤔🧐
Only when you select another folder again (second time), delete operation will be successful.

Tried several times with same results.
And as i remember, this bug i found some time ago, so it is not introduced exactly in last insiders build.

Visual Code Insiders 1.41.0 from 2019-12-02, commit: 7cf4cca
macOS 10.15.1

Activity

  1. ghost changed the title [-]Second folder delete operation fails in Insiders 1.41.0[/-] [+]Second delete folder operation does not work in Insiders 1.41.0[/+] on Dec 2, 2019
  2. added
    bug
    file-explorer
    on Dec 4, 2019
  3. isidorn commented on Dec 4, 2019

    @isidorn

    @ZaJarv thanks for filling this great issue. You should have the fix tommorrow in vscode insiders

  4. isidorn commented on Dec 4, 2019

    @isidorn

    João Moreno (@joaomoreno) the problem was that it was happening that the tree would sometimes set the trait on one element two times.
    In this particular case Selection would be set on the element A and A. So if I say tree.getSelection I would get the same item twice. Instead of the array with one item.
    I decided to fix this with a workaround on the trait level.

    Repro steps: set compact tree to true. Go up and down with the focus always ending up with the focus on the one select item.
    Put a conditional breakpoint here tree will try to set the double selection trait

  5. jzyrobert commented on Dec 4, 2019

    @jzyrobert
    Contributor

    Isidor Nikolic (@isidorn) This seems to be coming from here

    Where the selection would already contain the folder, but as oldSelection/oldFocus also has the id, it will push the same object to the selection again.

    You could also fix it there by doing some sort of duplicate filtering or selection.indexOf to prevent duplciates being added

    I could reproduce it consistently by:

    • Putting a breakpoint there
    • Creating a new folder
    • Focusing on that folder

    Result: The function ends up setting selection to contain the same object twice.

  6. isidorn commented on Dec 4, 2019

    @isidorn

    Robert Jin (@jzyrobert) great pointer. I think you are right, give me a sec and I will push a better fix. Thanks a lot!

  7. jzyrobert commented on Dec 4, 2019

    @jzyrobert
    Contributor

    Isidor Nikolic (@isidorn) I was planning to submit something along the lines of

    if (oldSelection.has(id)) {
    	const element = compressedNode.elements[compressedNode.elements.length - 1].element as T;
    	if (selection.indexOf(element) === -1) {
    		selection.push();
    		didChangeSelection = true;
    	}
    }
    if (oldFocus.has(id)) {
    	const element = compressedNode.elements[compressedNode.elements.length - 1].element as T;
    	if (focus.indexOf(element) === -1) {
    		focus.push();
    		didChangeFocus = true;
    	}
    }
    

    But I'm not sure if this is considered good code, it might be better to create a set of Ids (like oldSelection) does, but as selection is of type T, I could not access the id parameter.

  8. isidorn commented on Dec 4, 2019

    @isidorn

    Robert Jin (@jzyrobert) If you would like to create a PR you are more than welcome to! It would be great if you could do it today since we are wrapping up the milestone and we need this fix asap.
    Just make sure to remove my wokraound introduced with 6d2eeee

    Thanks!
    And make sure to ping me on the PR

  9. added a commit that references this issue on Dec 4, 2019
    7f04538
  10. added
    verified
    on Dec 5, 2019
  11. locked and limited conversation to collaborators on Jan 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugfile-explorerverified

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions