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 #3849 together with the LSP plugin.
merged master, fixed unconditional reopening of files. This is indeed beneficial, though the core issue with keeping right tab active after opening non-existent file from console is related to fact that we cannot manually activate tab that does not yet have underlying file saved to disk (we can activate it only by re-opening file from disc right now). So now everything works correctly, unless you put persistent temp file on disc manually and then open non-existent file from console - then focus will still be on a last-opened persistent file. Doesnt matter though