local-history
local-history copied to clipboard
Scan the history quickly
Currently the tracking of changes is working really well, as is the compare for seeing a diff.
What would make this REALLY good is:
-
being able to scan through the history without having to open up a new view. This should be possible because it's possible to view different files from the project through the Super+Shift+P menu. Currently I'm left guessing at where I was in my workflow to choose which file to open up. The plugin is only really useful for restoring from disasters, rather than for reviewing progress.
-
incremental diffs. While viewing the file using the aforementioned quickview method, show the diff from that version to the immediately subsequent version: This highlights exactly what was edited at that point.
I am not able to follow you! being able to scan through the history without having to open up a new view - to compare the current file with any previous version you have to open the diff in a new window.
Did you mean that for each compare you have to repeat the process of opening the history, compare file and show diff in a new view?
So. I just discovered the functionality yesterday where once you have a project with a folder open in it, you can do Super+P to bring up a project search menu. From there you can start typing, and it will show a list of all files in the project which fuzzy-match what you enter with filenames and paths. During this time as you arrow-through the choices you are also able to preview the pages in the text view below!
So, what I propose is for this plugin to do the following: A command will trigger a "this file's history" menu. This menu will be filled with the previous history of the file. The user can move through this list, and each one will display a diff from history entry i to history entry i+1 (incremental diff which shows the change that is relevant to the particular version being viewed). This way the user can (via the nicely syntax-colored diff) easily see exactly what he changed (in the text field) at whatever time entry he's looking at, and he'll be able to scan through the history quickly by simply going through the list.
To implement this I think the most straightforward method might be to generate all of these diffs in a temp dir once the command is invoked. Then all that's left is to fill the menu (same functionality as our Ctrl+P menu. I don't care if the menu lets me type anything so long as I have the ability to scroll thru history quickly) It should not take too unbearably long to generate these diffs but if it ever becomes a problem it probably wont be too difficult to make a command for clearing really old entries. Also, the plugin can store both these diffs and the actual snapshots, so the diffs wont even need to be computed!
What do you think? This would be SO DAMN awesome. I'm not a great python programmer but if I can't convince you that this is a good enough idea I'm probably going to fork and implement it myself.
Then, one last perfect addition to that is to auto-scroll to the first change in the preview, so that it clears the menu so it can be easily read. This would allow SUPER fast scanning and ease-of-use.
If this can be implemented I will never touch another editor ever again.
Thanks for your input, I am going to try that this weekend.
That's excellent!!! Please keep me posted on any and all progress.
I looked into the api and couldn't find a change event while browsing through the list of files using up / down arrow keys. I have put a question http://www.sublimetext.com/forum/viewtopic.php?f=6&t=7127#p30246.
Cool. Yeah I wonder how the Ctrl+P menu is implemented.
I haven't seen it exposed through api.
Hmm. How about a (temporary) workaround using a key-mapped command?
Does the API allow for the creation of a transient buffer? What I mean is a buffer that shows up like when you select something from the sidebar but don't edit the file (upon editing file, it becomes a real tab) This can be filled with the stored diff. So rather than arrowing thru the list, I can (for instance) Ctrl+Super+Left to go back and Ctrl+Super+Right to go forward through my history, and the diffs will be displayed in a buffer managed by the plugin. Probably prevent editing of these buffers as well.
I'm looking thru the API now and I agree there's nothing in there to let us do the Super+P live-view-list, but what I just suggested is almost as good and is probably even be faster to use! The date and time and revision of the file can be displayed in the bottom status bar.
For now, I have decided to work on incremental diffs and browsing them through some key combination.
That sounds great man. I'm pretty sure that will be a faster workflow than the Super+P live list because the full viewport is available for viewing the diff, and the same key-combination can be used to start searching history as well as keep going back in history, whereas with the menu we have to start it off with some command, then switch to using arrow keys (though using a mouse wheel to scroll both menu and buffer is still pretty damn awesome).
Another thing. Are there any shortcuts set to the "remove history" command? The history for one of my files has gotten truncated and I bet it's because I pressed something by accident. Perhaps you could not set a key binding by default for "delete history".
There is a delete all history command from tools > local history > delete all
So I found something strange today. Under ~/Library/Application Support/Sublime Text 2/Backup there are dated directories in which the Local History package (the entire package dir) is backed up. Inside .history/ in these backups exist my old histories of my files I've been editing. So I was wrong about the shortcuts causing this earlier, but I still have no idea what caused these backups to be made.
Do you know how I might change this behavior? Are the history files still usable if I copy them back into the package folder?
EDIT: Ah a little searching gives me the answer: When a package is updated, it gets copied to the Backups dir! So it just means you updated Local History (which I see you did). So when that happens the history gets copied off to Backups. So I needn't worry about this happening all the time.
It's taking too much of my time, for all this we really need to have an api expose listing the file from panel as transient buffer.
Check sublime.Window, open_file(file_name,
I was using the same, but as I open the diff file I will loose the original file view (which has all the context). I failed to save the view object. There is no way to tell if this view has been assigned a tab or not!
Hm. I'm not sure that's an issue though. If it gets assigned a tab, there's no problem. Can carry on moving through the history regardless of if the transient view becomes a tab or not. Is the original file view lost? or is it simply "hidden"? Ideally pressing Esc should bring it back to the original view (cancel the current transient view).
Anyways, thanks for your commitment to this project. If you do abandon it, I'll probably take a look at it myself. I'm not sure what the best way to test plugins is but I don't see how difficult it would be.
I tried all and the code became very dirty. I will keep it open until I get an answer to my question or some api is exposed to view files in a transient manner. Please feel free to fork and work on it.
Thanks
Added incremental diff feature!
I look forward to testing it! I'll post back.
Great! It works just like the other commands, which is consistent, which is good.
Are you continuing to work on it? Maybe I will fork and try my hand at implementing keyboard shortcuts to flip through the history, like I described earlier. Do you have some hints on how i might accomplish it?
I noticed you changed the .history directory so that it no longer gets copied out when the plugin is updated. That's great.
Do you think you can get a keyboard-issuable command which allows quick browsing of incremental diffs (in transient buffers if possible)?
Cool. Yeah I wonder how the Ctrl+P menu is implemented. http://www.sublimetext.com/docs/2/api_reference.html sublime.Window show_quick_panel(items, on_done,
)
ps:like your plugin very much.
@vishr I know you posted on the forum but have you done so here? http://sublimetext.userecho.com/
I posted a plug for this plugin on this topic: http://sublimetext.userecho.com/topic/20126-undo-even-after-closing-and-reopening-file-storing-entire-undo-history/
Thanks!
@vishr, @jrappen, +1.
Actual behavior for Local History:
Expected behavior like for Goto Anything panel:
Thanks.
@Kristinita I suggest you add a PR with the desired changes for @vishr to review.