One more problem - when you launch Geany from the command-line by ``` geany some_file.txt ``` where `some_file.txt` doesn't exist yet, the file gets opened in a new tab but the "persistent temp file" becomes the active tab instead. I haven't checked the code what Geany does exactly but the file apparently gets opened at some later point.
In any case, I believe this could be mitigated if inside `load_all_temp_files_into_editor()` you only call `document_open_file()` when the temp file isn't opened in any tab (by going through open documents and checking their path). This would also eliminate some other problems like when "Switch to last used document after closing a tab" is selected in "Notebook tabs" inside preferences which leads to switching to "persistent temp files" when closing some other tabs.
One more request - could you rebase this PR on top of current Geany master (or merge master into this branch)? I'd like to give this feature some more testing but in parallel test the recently merged https://github.com/geany/geany/pull/3849 together with the LSP plugin.