A little plug-in which remembers and restores the scroll and cursor positions, also the selections, folding, bookmarks and mark states.
Sublime already restore these things for tabs that are opened but not for closed tabs.
This plug-in provides persistence when closing and opening.
BufferScroll
All folds re-open when file is committed
Folding up a block of code
Keep closed off areas locked
sounds very useful but how is this supposed to work? code folding is not remembered in my case (both for project switching as well as for restarting ST2). I am running 2134 on Mac OS 10.7.
Thanks!
Nice catch.
The plug-in saves the āstateā when the tab is closed, an optimal and non obstructive way.
As Iām seeingā¦ unfortunately sublime is not sending āon_closeā event when switching projects. In a similar way sublime is not sending āon_closeā when the application is closedā¦
Then, the plug-in miss the data because is not informed.
A workaround is to save the data when the tab lose focus(on_deactivated). But that means 1 write every time you switch a tab or the tab lose focus, unnecessary, dirty and not optimal.
Also, another problem is that folded regions can be obtained by unfolding the actual folds, this means every time you switch a tab or the tab lose focus the buffer need to be unfolded and refoldedā¦
Iāve added the workaround to the plug-inā¦ update and please be informed Iām not happy and complete dislike this solution.
[edit] - Another problem is that the application by default tries to do its own restoration but this is not working properly for most of the files. then I need to put a time-out to not get my restoration overwrited, which is something I dislike too.
I see the problem. tab switching within projects already preserve code folding and cursor position so I agree that the save is unnecessary in that case.
Whatās about saving the data when
(a) āon_closeā (already implemented)
(b) something like āon_saveā. That takes care of the application close as long as the user saves the file before closing the project. Itās also not optimal because the user might save the file, do some code folding and then close ST2.
Ā© When some project switch event is fired. Does that exist?
Iām afraid there is no event for project switching.
BTW, Sublime should send the on_close event when switching projects and when closing the application.
I made some little tweaks and added support for bookmarks and marks.
There is a little bug reproducible even without this plug-in that the first focused tab on switching projects sometimes donāt want to scroll, it stay on line 2.
I can live with that. : P
Regards
This plugin has the following bug:
When the same file is opened on different columns/rows, looks like there is no way to detect on which column/row/group the file is. On restoration all the diffferent column/row/group of that file will get the same scroll, bookmarks, selections, etc.
Looks like there is a need to know an ID of the position in the editor for a view. such āgroup+column+rowāā¦ any API?
Looks like there is a need to know an ID of the position in the editor for a view. such āgroup+column+rowā
Yes, good fellow, yes!
I get a bit of āspamā in the console when I use your plugin (ST 2, v2165 portable):
app ready
pre session restore time: 0.277987
Traceback (most recent call last):
File ".\sublime_plugin.py", line 211, in on_deactivated
callback.__module__, "on_deactivated", EVENT_TIMEOUT)
File ".\sublime_plugin.py", line 155, in run_timed_function
ret = f()
File ".\sublime_plugin.py", line 210, in <lambda>
run_timed_function(lambda: callback.on_deactivated(v),
File ".\BufferScroll.py", line 33, in on_deactivated
File ".\BufferScroll.py", line 77, in save
AttributeError: 'View' object has no attribute 'folded_regions'
wrote startup cache, added files: 2 orphaned files: 3 total files: 127 cache hits: 125
startup time: 0.362697 (package setup was not run)
loaded 941 snippets
Traceback (most recent call last):
File ".\sublime_plugin.py", line 211, in on_deactivated
callback.__module__, "on_deactivated", EVENT_TIMEOUT)
File ".\sublime_plugin.py", line 155, in run_timed_function
ret = f()
File ".\sublime_plugin.py", line 210, in <lambda>
run_timed_function(lambda: callback.on_deactivated(v),
File ".\BufferScroll.py", line 33, in on_deactivated
File ".\BufferScroll.py", line 77, in save
AttributeError: 'View' object has no attribute 'folded_regions'
I have several files open but none of them is a duplicate (e.g. via āclone fileā) of each other.
Regards,
Highend
Hi,
I have these lines with v2012.01.18.09.38.14, there isnāt any newer version available.
Regards,
Highend
You say you have version 2165 of portable edition.
Can you please open the console and paste the output of the following:
sublime.version()
Itās crazy because the line your are quoting is for greater versions.
github.com/SublimeText/BufferSc ā¦ oll.py#L76
Thanks
I think the package is outdated. Or Iām not seeing something very obvious.
Can you check if the file
github.com/SublimeText/BufferSc ā¦ rScroll.py
is the same to āPackages/BufferScroll/BufferScroll.pyā
Regards
Yes, they are identical (checked with Beyond Compare).
Maybe itās the āuā in front of the ā2165ā version number, that confuses your version check?
Regards,
Highend
Ok I see the error downloading your version.
sublime.version() returns a string instead of an int, and the check for version fails.
Fixed. Thank you
Thatās, IIRC this version checking was working on previous versions, tested with SideBarEnhancements.
Confirmed, itās fixed. Thank you!
Is it normal that it reloads itās settings file (./Data/Packages/User/BufferScroll.sublime-settings) on each tab change / clicking on a file in the sidebar (just for the preview, not via doubleclick to load one)?
Regards,
Highend
Yes, because the application is not sending or do not want send some āeventsā such:
1 - Closing the application
2 - Closing a project
3 - Opening a project
Sorry for the message I have no control over that.
Regards,