Home Download Buy Blog Forum Support

Please fixme: A reproducible bug in set_viewport_position

Please fixme: A reproducible bug in set_viewport_position

Postby tito on Wed Mar 21, 2012 11:20 pm

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
Code: Select all
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 :
Code: Select all
>>> 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.
Code: Select all
>>> 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.
Last edited by tito on Sat Mar 30, 2013 8:38 pm, edited 1 time in total.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 855
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: A reproducible bug in set_viewport_position

Postby tito on Wed Mar 21, 2012 11:32 pm

This is very strange because is only happening with some file types.

For example if I rename Monokai.tmTheme to Monokai.css this is not reproducible.

This seems to be reproducible with xml, txt, html and I don't know if more files.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 855
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Please fixme: A reproducible bug in set_viewport_position

Postby tito on Sat Mar 30, 2013 8:51 pm

I just updated the example:
Code: Select all
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())

Save this a bug.py
-----
- Open a big file, with more than 30 lines
- The first time it opens is stay at line 1.
- The next time you open this file will scroll correctly.

Problems:
Now not only the view is not scrolled, the following API call is lying.
Code: Select all
print (view.viewport_position())

is printing
Code: Select all
(0.0, 500.0)

But that is not correct because the first visible line is 1. And also this is confirmed by
Code: Select all
sublime.active_window().active_view().viewport_position()

Which display
Code: Select all
(0.0, 0.0)


It looks like sublime text, overwrite the scroll the first time the file is opened.
The problem is always reproducible when you open a file from -> File -> Open Recent -> Pick the file.

Please fix! :roll:
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 855
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Please fixme: A reproducible bug in set_viewport_position

Postby tito on Tue May 28, 2013 10:38 am

bump
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 855
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay

Re: Please fixme: A reproducible bug in set_viewport_position

Postby lmartins on Mon Jul 01, 2013 10:25 am

Please fix this. BufferScroll relies on it and it is an invaluable plugin.
Thanks.
lmartins
 
Posts: 1
Joined: Mon Jul 01, 2013 10:24 am

Re: Please fixme: A reproducible bug in set_viewport_position

Postby tito on Sat Jul 06, 2013 5:30 am

^ Creating an account to just post this, deserves a fix :P, unfortunately, not on my end.
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 855
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay


Return to Technical Support

Who is online

Users browsing this forum: No registered users and 13 guests