Hi,
I found a way to reproduce a bug found in “set_viewport_position”
1 - With default sublime installation and no plugins. Even with all the default py files uninstalled (this makes no difference).
2 - Save this script as file set_viewport_position_bug.py
import sublime, sublime_plugin
class setviewport_bug(sublime_plugin.EventListener):
def on_load(self, view):
view.set_viewport_position((0, 500), False)
print view.viewport_position()
This will set the vertical position to 500 on every file you open.
3 - Now open a big file via “main menu bar” -> “file” -> “open file”
I selected for convenience the file “Packages/Color Scheme - Default/Monokai.tmTheme” (please select the same file.)
You will see that the view port is scrolled correctly to 500.
You can check this from the console with :
>>> sublime.active_window().active_view().viewport_position()
(0.0, 500.0)
4 - Now, here is the bug.
Open the same file via the sidebar. And you will notice that the view is not scrolled.
>>> sublime.active_window().active_view().viewport_position()
(0.0, 20.0)
It stay on (0.0, 20.0). I’m not sure the reason on this, but it seems that there is something in the sidebar that is setting this value to 20.
This same thing happens when using “CTRL+P”, so I guess this has somthing to do with the code of the “preview”
Can you please do a quick check if there is something there overwriting this value. Because most of the time is unusable and this api is very handy.
I would recommend to use the file “Packages/Color Scheme - Default/Monokai.tmTheme” because the problem is reproducible 100%
Thanks.