Home Download Buy Blog Forum Support

refresh viewport on view selection change

refresh viewport on view selection change

Postby chrisguilbeau on Wed Feb 22, 2012 4:49 pm

When I set the cursor to a different position programmatically the cursor is not redrawn in the viewport until I change the viewport by clicking somewhere, or scrolling. Is there a way to make the viewport refresh? Here is what I'm doing inside of a WindowCommand where lastCurPos is a function returning a (row, col) tuple from a history of cursor positions

Code: Select all
            v = self.window.active_view()
            row, col = lastCurPos()
            point = v.text_point(row, col)
            v.sel().clear()
            v.sel().add(sublime.Region(point))
            v.show(point)
chrisguilbeau
 
Posts: 19
Joined: Fri Nov 11, 2011 5:06 am

Re: refresh viewport on view selection change

Postby colinta on Wed Feb 29, 2012 7:00 pm

I'm having the same behavior. I've added a bug on sublimetext.userecho.com for this (please upvote!)

http://userecho.com/FZqP
colinta
 
Posts: 15
Joined: Wed Dec 21, 2011 9:43 pm

Re: refresh viewport on view selection change

Postby colinta on Wed Feb 29, 2012 7:13 pm

very hacky solution (for plugin authors):

Code: Select all
pos = v.viewport_position()
v.show(point)
new_pos = v.viewport_position()
if abs(new_pos[0] - pos[0]) <= 1.0 and abs(new_pos[1] - pos[1]) <= 1.0:
    v.set_viewport_position((new_pos[0], new_pos[1] + 1))
colinta
 
Posts: 15
Joined: Wed Dec 21, 2011 9:43 pm

Re: refresh viewport on view selection change

Postby makc on Wed Dec 18, 2013 7:25 pm

makc
 
Posts: 8
Joined: Wed Dec 18, 2013 7:22 pm


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 13 guests