Slow to close multiple documents
What Happened?
Closing a project where many documents are open e.g. >10 takes many seconds during which one of the cores is maxed out.
Active plugins: Brackets completion Detect Indent Editor Config Outline Strip trailing spaces Word completion
Steps to Reproduce
- Open a project
- Open and edit multiple documents
- Close the project
- Wait many seconds for the documents to finish closing
Expected Behavior
Only a modest delay (not caused by processor overload) should occur when closing a project with an average power machine with spinning disk storage and a typical number of documents open when developing.
OS Version
7.x (Early Access)
Software Version
Latest release (I have run all updates)
Log Output
No response
Hardware Info

It was subsequently noticed that after closing the project, Code was still sluggish to respond even with no projects or documents open and e.g. switching plugins on or off consumed considerable cpu. Closing Code and relaunching it restored responsiveness. So this seems related to some continuing burden imposed by extensive use.
I noticed this behavior while closing tabs in a project with multiple documents open. Turns out this function was executing every time a document is closed:
https://github.com/elementary/code/blob/186246b7efafc8e6f32b29dcca5971c9aa322806/src/Widgets/DocumentView.vala#L445-L457
It's expensive and will block the main thread. In my testing I was able to avoid these stalls by disabling history under System Settings > Security & Privacy > History. Disabling this feature causes the conditional to fail, skipping this codepath entirely.
@eczarny Thanks for investigating this. I haven't found time to do so yet. I'll try and make some improvements based on your findings.