Save/restore queries on close or manually
I'm a multitasker, and I usually have 7 or 8 (or 20) tabs open in LINQPad. When I need to restart my computer, or for whatever reason close LINQPad, I could to save each of my queries (coming up with a meaningful name for each), remember which ones I had open, and reopen them one by one when I restart, but I find it's quicker and easier to just kill LINQPad with Task Manager so that it will offer to reload all my tabs for me automatically. I would be nice if LINQPad had the option to save and restore all queries on close/start, and/or the option to save and reload a group of queries at will.
This is now available from V6.9.12 (in beta as of June 2020). It employs a new autosave engine that serializes all editor operations, so that the undo/redo stack is restored along with the query. You can choose to shelve queries upon exit, or by default in the Edit | Preferences dialog. A conflict-detection mechanism ensures that you can’t accidentally overwrite a query that’s been subsequently edited via cloud synchronization or another application. Enjoy!
Marc Selman commented
I would really like to see this implemented.
Option (a) is mostly neccessary but for option (b) maybe you could:
Save the query as an untitled query (same as (a)) but save the original saved query file location as meta-data.
Then, when opening Linqpad again, all unsaved queries can open and if there's a file location as meta-data available, just check if that file still exists and open that file and replace the contents with the unsaved query.
Aaron Bauman commented
Automatically save untitled queries.
Ask to save titled queries.
SQLPrompt does this and it hasn't bothered me yet.
Yaroslav Veremenko commented
+1 for behavior like Notepad++ On exit do not save the queries, but load them as it was closed and mark them unsaved.
Pretty pretty please (b). Having this feature would pretty much mean my whole taskbar works the same way. (Notepad++, all the jetbrains stuff (phpstorm, datagrip, dotpeek etc), and chrome)
James Curran commented
I was about to write that I'd be happy with (A), since saving a named file involves just clicking the toolbar icon --- then I realized that LINQPad doesn't have a "Save FIle" icon. GIve me that button, and I'd be happy with option (a).
I wasn't kidding about buying LINQPad again for this feature. I've pre-emptively kept my word by just now buying a 2nd user license. GO LINQPAD!
Joe: in response to your feedback request, I believe mimicking the behaviour of notepad++ would make the community happy, since then we wouldn't need to remember which application behaves in which manner
Carl Kelley commented
I usually have many queries open in LINQPAD 5 when I close it. LINQPAD already prompts me whether to save modified queries before closing. What I'd really like it to do is re-open those queries when I restart LINQPAD so that I don't have to hunt around for them.
I vote for option (b). However, applying it to saved queries means that next time I open LINQPad, their state is all the same, the edits I made are still there, in the editor, but not in the files. A temporary version should be maintained at all times like in Sublime Text.
Drew Noakes commented
Best option is to follow the lead of editors such as Notepad++ and Sublime Text:
When the user closes and reopens the program _NOTHING CHANGES_.
That is, all buffers are exactly as they were. Any unsaved changes are still unchanged.
Once you use this feature for a bit, it feels amazing. There's no cognitive barrier to closing the program, because you know it'll be there when you get back. It mightn't be the easiest to implement, but it's not so bad in reality, and it truly is the gold standard in behaviour, IMHO.
Tim May commented
Adam C commented
(b) -> I would expect it to act like other text / code editors, re-opening everything in the same order and same state as before, just like it does if the task is killed.
It would also be nice sub-feature if we could choose where the session / autosave is stored. Occasionally my restored session is lost and some in-progress queries that I needed were also lost.
but having to choose between a or b, I'd take b so as not to lose anything...
(sorry I went a bit overboard in my previous answer)
My personal use case is that I usually am in a context, tackling a specific problem (like "building a specific export/tool/whatever for client ABC", usually working at or for client ABC at that precise moment. Then at the end of the day, I close shop, ending up with dozens of opened tabs...
During the night, the computer could reboot (the dreaded update, or whatever)... or I could have to run to school fetch the kids, or whatever, closing the computer in haste... risking losing all my tabs...
Or in between work sessions for client ABC, there could a session for client DEF...
Ideally, for me, I could just close the app, it would save the context of that specific moment, and I could reopen the app afterwards, choose the saved context from a list (by date, if not named, by name like "context client ABC" "work for DEF" or "ABC" and "DEF", If I took premptively the time to name that context, or change the name afterwards... ) and "voila" I would be back to the point I left.
Optionally, context "ABC" from week04 would coexist with context "ABC" from week07... ;)
Mike D. commented
I vote for (b).
Feature (a) is also nice, but, if there are both untitled files and modified saved files in the session, the behavior of (a) may cause some confusion.
I think the behavior of (b) is easy to understand for users, because all unsaved modifications are kept.
Option (a) is what what I am looking for.
Mark Hurd commented
Mostly thinking of (b) here because that does seem to reflect the current functionality: when you kill LP from Task Manager that's the functionality I see.
Scott Gartner commented
If I had tabs open to saved documents (tabs that refer to specific files) then when I close LinqPad it should ask me if I want to save all documents, and if I say "yes" then it should attempt to save any documents that are open. If I have a bunch of "unsaved" documents then I should be able to cancel out of that "save" so that I can either save the "saved" documents, save all documents, close some documents, etc.
Basically, the way I was envisioning it working (if I were adding this feature) is that every tab would have a file associated with it. The tabs that I explicitly saved or opened would be associated with the explicit file, the rest would be associated with temp files (somewhere). But they would be tagged as "unsaved" while they only point to a temp file. I would then store somewhere that I had these, for example, seven files loaded, four to "real" files and three to temp files.
I believe this matches now Notepad++ works (though I've never looked into where NPP stores the "unsaved" files).
Michel Bretschneider commented
Voting for b here.
b) would be best (and final solution)
a) still provides a significant improvement, so if b takes more time, going with a first and b after that would "deliver continuous value" here.