Home Download Buy Blog Forum Support

BUG?: reopen command steals focus and creates a new tab

BUG?: reopen command steals focus and creates a new tab

Postby wuub on Thu Dec 01, 2011 2:25 pm

In one of the previous thread I announced a new plugin: SubARWE that automatically reopens file with a correct encoding specified in a magic comment.
It works reasonably well but there are some issues that I am unable to solve by myself.

SubARWE fires on_load(), and if the current encoding is different from the required one, calls view.run_command("reopen", {'encoding': req_enc}).

1) However, this completely breaks "Goto Anything". As soon as Goto Anything displays a preview of a file with a magic comment understood by SubARWE, "reopen" is issued and view steals focus from GA panel. GA panel remains visible, but the rest of the typed chars go to previewed file and not the GA.

2) Calling "reopen" on a file that I'm only previewing (w/o opening a new tab) causes it to get a new tab.

@jps: Is there anything I (we?) can do about it? I work with a pretty big codebase that I don't fully control (think 150MB of code, *excluding* resources or config files) that uses at least 4 different encodings. Reopening files manually with a correct one is IMO against ST2 philosophy. But I hit a wall and don't know how to automate it w/o breaking basic Sublime functions.

code: https://bitbucket.org/wuub/subarwe/src/ ... subarwe.py
SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 218
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland

Re: BUG?: reopen command steals focus and creates a new tab

Postby senzo on Thu Dec 01, 2011 3:25 pm

There seems to be a solution to at least identify if it is a preview:
http://www.sublimetext.com/forum/viewtopic.php?f=5&t=3853
Maybe this helps to suppress the reopen in this case.
senzo
 
Posts: 106
Joined: Tue May 24, 2011 9:17 am

Re: BUG?: reopen command steals focus and creates a new tab

Postby jps on Fri Dec 02, 2011 9:32 am

I'll tweak the focus handling logic for the next dev build so it won't get tripped up in this scenario
jps
Site Admin
 
Posts: 3071
Joined: Wed Mar 19, 2008 12:33 pm

Re: BUG?: reopen command steals focus and creates a new tab

Postby wuub on Fri Dec 02, 2011 3:05 pm

jps wrote:I'll tweak the focus handling logic for the next dev build so it won't get tripped up in this scenario


Thank you.
SublimeREPL via Package Control & SublimePTY dev/pre-alpha. Donations are appreciated, but not required :) Twitter: @wuub
wuub
 
Posts: 218
Joined: Wed Aug 10, 2011 8:16 am
Location: Poland


Return to Plugin Development

Who is online

Users browsing this forum: Yahoo [Bot] and 10 guests