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!
-
Dennis Jones commented
Absolutely LOVE this feature! Thank you! This feature alone was worth paying for the upgrade to version 6!
-
Anonymous commented
Thank you Joe for the hard work you put into creating this amazing application, I can not longer see myself working without LinqPAD by my side
-
Ireneusz commented
I am using Notepad++ as a... notepad ;) I very rarely save files. I do have some notes there organized in tabs.
I've just checked and it does (b) quite well. It's keeping the state of unsaved files (not only untitled ones). What's more interesting is that when I make a change in a file, don't save it, quit Notepad++, make another change in different editor and get back to Notepad++ it detects there was a change (most likely it keeps modification date of the file to do that) and asks what to do (reload the file from disk or from its own buffer). Both options will lead to lost changes but you're the one to pick which ones to lose.However for LINQPad I'd rather go with (a) if (b) is too complicated.
That will cover 90% of the cases when I do have many untitled tabs which I often lose. -
Craig commented
It's really weird that this feature still isn't in LINQPad. It's really annoying having to save queries so that I can use them next time I open LINQPad and then have to remember to do regular cleanup once I no longer need them.
"(b) creates numerous complications". I haven't sat and thought about it, but I can't think of a significant complication. The closest I can think of to a complication is if the file has since changed in some way. If the file was changed after closing would likely be covered by keeping track of the file's last updated time. So instead of only keeping the temporary file name and the original file location that it referenced, keeping the last updated time. The file could be deleted, of course, but that's dealt with easily since a check would have to be run to compare the stored last updated time with the current one. VS Code, for instance, then just notifies the user by putting '(Deleted on disk)' or something like that in the tab title after the original file name.
I don't think users are expecting the app to protect them from themselves. Are the complications things to do with trying to achieve that?
-
Hmayed commented
Notepad++'s approach would be great
-
Lance May commented
VS Code's approach of keeping 'untitled's and actual files as they are on close is perfect. Seems like keeping your editor's state is handled completely separate from file saving and loading is the way to go. Also seems like this is becoming a popular trend (and rightly so).
-
Geoff Slaughter commented
Hi Joe, looks like it would be hard to satisfy everyone with a binary choice so my 2 cents would be a setting to define save behaviour (lots more work I'm sure):
a) always prompt (as-is)
b) don't prompt:
- 1) dispose of unsaved changes
- 2) autosave all
- 3) autosave untitled only -
Erdoğan Kürtür commented
I believe it would be best if it works like Sublime Text.
It reopens as if nothing happened. New and unsaved files are restored, edited files reloaded as unsaved. As if program not terminated and restarted but somehow hibernated.
I believe sublime does this by recording everything in a work space, and reload this workspace so nothing is lost
-
Oleksii Vynnychenko commented
Honestly, it seems like LinqPad is almost dead in terms of new features. This ticket is almost 8 years old and it's 2019 out there. Feature of auto-saving current session is a must for tool that intended to be opened/closed frequently that LinqPad is.
Currently I'm using RoslynPad when I feel like I won't need to debug (the only feature that makes LinqPad unique for me) just because it provides that expected in 2019 experience of:
"Run the tool and it will open at place where you left -> do your stuff -> close without thinking if your session will be lost or not".
Look at Notepad++, RoslynPad, etc. - that's how good tools that intended to open/close frequently are designed. -
Raimonds commented
I would like "Notepad++" approach too - reopen tabs as they was before closing. It's simple and intuitive, for use as scratchpad with autosave feature too. Same here - often i do some code tests in Linqpad, with multiple important code fragments opened in different unsaved queries. OK, there is bruteforce 'end task' solution, but it is inconvenient and also it doesn't work for windows insider 'fast ring' machine due to frequent OS updates. At least, if possible - keep unsaved (new and untitled) queries …
-
Anonymous commented
I would love this too.
When you reopen LinqPad it should be the way it was when you closed it.
If this is not easy, at least it should open the last opened saved queries. -
Dennis Jones commented
Personally, I would NOT want it to apply to named queries, only unnamed queries, because those are the ones that are lost if you close LinqPAD without saving/naming them. Also, oftentimes, I make changes to named queries that I don't want to save.
So my vote is for this to apply to UNNAMED QUERIES ONLY.
-
Roy LIANG commented
Even the most simple idea of saving a list of files (names) to a project, then loading a project opens all these files would be very helpful.
-
chojrak11 commented
I think it should be similar behavior to what VS Code offers. Saved documents that were modified are just saved, untitled/unsaved documents are persisted in some temp area (in Local portion of user profile) and all of them are reopened next time LinqPad is started, in the same tab order. Thanks.
-
Union Palenshus commented
Came here to request this feature and found out I'm in good company. I use the same workaround as everyone else, killing it with taskman, but this would make a lot more sense. Notepad++'s solution would work great for this. Joe, any update on this? Thanks!
-
Chris Core commented
Infact, just implementing the behaviour that already exists when killing the LINQPad process would work perfectly well imo.
-
Chris Core commented
@Daddy, you can do this now (although with a bit of workaround) by killing the LINQPad process in task manager. Seems that LINQPad has some kind of crash recovery built into it, so doing this will prompt you to re-open unsaved queries next time you launch :)
R.e the feature behaviour, I also think it would be great to emulate the way that notepad++ deals with this.
-
Brad commented
Option (a) would be nice, but (b) would be better.
What I'm actually hoping for would just be to keep a list of open tabs (saved or not) that will be opened, but have that setting be localized. That way if I have two different portable deployments of LINQPad for different contexts, then I could open either of those windows and get back the tabs I was working on previously, for that specific portable deployment.
This would be awesome!!! thanks for considering it!
-
Marty Casey commented
I could really use this. My workaround of killing the process so LinqPad restores itself when I relaunch it is cumbersome to say the least.
-
Jude Melancon commented
(b) does no harm over (a) obviously, but (a) would provide most of the benefit to my personal usage.