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.
I need some feedback on this feature. First:
(a) Would you expect it to apply only to untitled queries? Or:
(b) Would you also expect it to apply to saved queries that were modified?
(The reason I ask is that option (a) is simple to implement, whereas option (b) creates numerous complications.)
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.
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 …
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.
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.
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.
Shukhrat Nekbaev commented
definitely some solution is required. For example like in Notepad++.
I was also killing the process to preserve, but just now it started clean, I had tabs created in the last two or three weeks (I don't reboot that frequently). You can imagine my frustration ATM :( And it's not the first time either...
P.S. licensed user.
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)