When "load files from the last session" is enabled, regardless of whether a project is loaded, the previously active document is reactivated when Geany is closed and restarted with a document at the command line or from a file manager. The expected behavior is to activate the newly opened document for editing.
This occurs with the default config and no plugins loaded. Does not occur in an old build from 2021-12-30. Does occur in builds dated after 2022-05-01. I did not build Geany between those dates, so don't know when the new behavior was introduced. I do not see it in the manual, nor do I see any option to revert to the old behavior.
To reproduce:
1. Open Geany. 2. Open a several of documents. 3. Close Geany. 4. Open Geany with a file from a file manager or command line. 5. Geany will open and activate the last active document. Expected behavior is to activate the newly opened document for editing.
Nor is the old behaviour actually specified, but makes sense. @kugel- is this a side effect of the session split changes?
Caused by #3125 where I changed the "switch to last active document from session" to a `g_idle_add()` mechanism, and that's now run after command line files are opened.
Guess it should just select to switch to last document from session or last CL file opened if there are any.
I don't remember specifics, but I had previously noticed that Geany treats the command line differently when opening files in a new instance vs opening files in an already open instance so that some combinations of parameters and files would behave differently. I believe the cause is differences between code in `socket.c` and elsewhere.
Assuming the new behavior described in this issue is not intentional, would it make sense to unify command-line handling generally? For instance, upon starting a new instance of Geany, `socket.c` could be used to handled opening all files passed through the command line.
In case the behavior described in this issue is intentional or won't be fixed, here is a script that somewhat restores old behavior: ``` #!/usr/bin/env bash
# this script works around behavior where geany does not activate newly # opened documents on start, but does when arguments are passed to an # already running instance
GEANY_EXEC="/usr/bin/geany" DELAY=0.5
if pgrep geany ; then if [ $# -eq 0 ] ; then # bring already running instance to foreground xdotool search --desktop 0 --onlyvisible --class geany windowactivate else # pass arguments to already running instance $GEANY_EXEC "$@" & fi else # run geany, then pass arguments to new instance $GEANY_EXEC & [ $# -ne 0 ] && sleep $DELAY && $GEANY_EXEC "$@" fi ```
I would like to give a feedback to the code mentioned above. This is what I did: Because in `~/.local/` there was no folder `bin`, I created a folder `bin`. In that folder `bin`, I created a document with the name `geany`, with the code mentioned above as content. In `/usr/bin/` I looked for a document with the name `geany`, just to check if the path of `GEANY_EXEC="/usr/bin/geany"` is correct. Then I did in the terminal `sudo chmod +x ~/.local/bin/geany` to make the script executable. In the script `geany` that is located in `~/.local/bin/`, I changed `DELAY=0.5` from `0.5` to `0.6`, because the used computer is not so fast. Then I saved the document. The script works perfect for me.
I intend to restore the old behavior but it's not as simple as it seems, sorry, may take a while.
@kugel- I wasn't sure if it was intentional because no one had previously stated otherwise. Since there's a workaround and it took 3-4 months for anyone to even notice the change, there doesn't seem to be much need to hurry.
Well most users don't use Geany from the master branch but the last release. So I think 3-4 months vs a few days doesn't mean much.
It would be good if this issue will be fixed before Geany 1.39 will be released.
Closed #3210 as completed via #3267.
github-comments@lists.geany.org