IntelliJ can create with initial content (e.g. Java files with public class ... already written) based on a template engine. Unfortunately it inserts the content in the file before adding DocumentListeners, so we currently intercept them with a FileSystemChangeListener that listens for just-created files.
So far I assumed this happens in one pass: Create the file, fill it with template.
Apparently sometimes there is a second pass: Create the file, fill it with template, remove unused lines.
The 2nd case happens for example when creating a java class in the default package - in the first pass it will get a package header line
package PACKAGE_NAME
in the second pass this will disappear.
I think this is a minor issue since it can be solved by InconsistencyRecovery and probably does not happen so often, so I'll postpone a solution here.
The initial workaround does not work correctly. See #889.