Sublime Forum

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

#1

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: bitbucket.org/wuub/subarwe/src/ … subarwe.py

0 Likes

Dev Build 2145
#2

There seems to be a solution to at least identify if it is a preview:
https://forum.sublimetext.com/t/nopreviewplease/3227/1
Maybe this helps to suppress the reopen in this case.

0 Likes

#3

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

0 Likes

#4

Thank you.

0 Likes