Tested with Windows look and feel.
Get some data sources with loaded table data.
In Database window expand the tree up to some deep level.
Open an .sql file in editor.
Add a space in the end of any line.
Result: the tree in Database window is collapsed.
It preserved its state some builds ago.
Now the table nodes (with columns) are collapsed, but not database node. This is somewhat reasonable compromise for now.