Closed krasa closed 5 years ago
Deleting has the same effect. (and with proper 0.6.3 beta)
I think this also happens in older versions of IJ (e.g. in 2019.1) but I could only reproduce it with a task running in background, e.g.
Yeah I think it was there from the beginning. I can reproduce it without it, almost always, but not in pom.xml files, plaintext works great.
If I am long enough in the Add dialog, so that this popup disappears: then it works fine, because as the popup gets automatically shown, the tool window gets repainted with it.
I could try to fix it if you want.
Sure, if you want give it a go 👍
I think fundamentally the problem is that the way file tree is created in PluginToolWindow
is just a hack. My plan was to look at the latest IJ API to find what is the "right" way to do it these days but I don't mind any other fixes :)
Why don't you use LivePluginAppComponent#livePluginsPath as the tree root + filter to get rid of .idea folder? It would solve everything.
If you mean addRoots
function, then as the comment below says it's because of the case when there is only one plugin, the tree was doing something funny and basically automatically changing root to one level down. IIRC it was true in 2013, might not be true anymore though.
private fun addRoots(descriptor: FileChooserDescriptor, virtualFiles: List<VirtualFile>) {
// Adding file parent is a hack to suppress size == 1 checks in com.intellij.openapi.fileChooser.ex.RootFileElement.
// Otherwise, if there is only one plugin, tree will show files in plugin directory instead of plugin folder.
// (Note that this code is also used by "Copy from Path" action.)
if (virtualFiles.size == 1) {
val parent = virtualFiles[0].parent
descriptor.roots = if (parent != null) listOf(parent) else virtualFiles
} else {
descriptor.roots = virtualFiles
}
}
Yes, and seemed to work fine now.
Hm, to me it looks like it hasn't changed 🤔
I don't mean though there is no way to actually fix it instead using this hack.
Actually, what you suggested look like this
What I did:
descriptor.setRoots(VfsUtil.findFile(Paths.get(livePluginsPath),true))
instead of
PluginToolWindowManager.addRoots(descriptor, virtualFiles)
looked totally the same as the current solution. I will check other IDE versions.
works fine on 2018.3, maybe OS dependant?
Well, I reproduced this, several times, but only in sandbox there were plugins shown after start, but then just disappeared. After that the tree did not work at all.
Ok I know where was the problem. I found a nice little method VfsUtil.findFile(path, true)
, but it returns a VirtualFile even for non existing directory (both #exists and #valid return true) - looks like a bug in IJ... Gradle or something must have deleted my directory, so the tree had it's root, but the root folder did not really exist, and when it got created it did not make a difference.
https://user-images.githubusercontent.com/28375/59522398-835ba180-8ec6-11e9-8275-29b2cc413319.png That was caused only by not disabling the action when there are no plugins.
It looks like this:
Resizing or hovering over buttons fixes it: