From 7afc3eeedd77d6e871e764cb63fb7e794df7e604 Mon Sep 17 00:00:00 2001 From: Arun Prakash Jana Date: Fri, 13 Nov 2020 11:31:11 +0530 Subject: Fix #777: input stream ishould trump -s/-S If an input stream is available, prioritize that over sessions. find/grep syntax can be very complex and can be scripted. On the contrary, sessions can be loaded at runtime and the persistent session can be "restored". An interesting use case is the listing is done in picker mode from a script and the user expects to "pick" some entries among the listed search results. Another important change is - if the user tries to load the "last session" explicitly by name instead of using the session option _restore_, we should not overwrite the "last session" ("@") before loading the it. --- src/nnn.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src') diff --git a/src/nnn.c b/src/nnn.c index 154a330..78c9546 100644 --- a/src/nnn.c +++ b/src/nnn.c @@ -3955,6 +3955,10 @@ static bool load_session(const char *sname, char **path, char **lastdir, char ** return FALSE; mkpath(ssnpath, sname, spath); + + /* If user is explicitly loading the "last session", skip auto-save */ + if ((sname[0] == '@') && !sname[1]) + has_loaded_dynamically = FALSE; } else mkpath(ssnpath, "@", spath); @@ -7687,6 +7691,9 @@ int main(int argc, char *argv[]) /* We return to tty */ dup2(STDOUT_FILENO, STDIN_FILENO); + + if (session) + session = NULL; } home = getenv("HOME"); -- cgit v1.2.3-70-g09d2