Project Folder pane is mutable too much

How can I prevent to drop a folder inside an other folder accidentally per mouse? I just use the pane folder on the left and find it very bad if you can make changes so easily (and accidentally). I could not find any way to undo this?

Also, is it possible to sort files inside a folder of the pane by date?

Add the following to your user stylesheet:

.tree-view {
    .list-tree.has-collapsable-children .list-nested-item > .list-tree > li {
        -webkit-user-drag: none;
    }
}

Yes, here is a very basic example script you could add to your init.js:

const fs = require('fs');

// Helper function to get modified time of a file
function getFileTimestamp(listItem, sortBy = 'mtime') {
  const filePath = listItem.querySelector('span[data-path]').dataset.path;
  const timeStamp = fs.statSync(filePath)[sortBy];

  return new Date(timeStamp).getTime();
}

// Get all list items in the tree-view
const listItems = document.querySelectorAll('.tree-view .list-tree li');

// Sort by timestamp
const sorted = Array.from(listItems).sort((a, b) => {
  return getFileTimestamp(a) > getFileTimestamp(b) ? -1 : 1;
});

// Empty tree-view
const listTree = document.querySelector('.tree-view .list-tree')
listTree.innerHTML = '';

// Add sorted items
sorted.map(el => {
  listTree.appendChild(el)
});

This example is a good starting point. There are several pitfalls to consider:

  • there is no error handling, e.g. this will fail when there is no tree-view
  • this does not update on new files
  • this does not update on files saves

Good luck with that!

PS: I think it’s a terrible idea, don’t say I didn’t warn you