I’m trying to implement python live coding as a plugin (https://donkirkby.github.io/live-py-plugin/). I’ve got a basic implementation working, however running into an issue where my window loses focus after a call to subprocess. To repro, create a plugin using the snippets below:
Main.sublime-menu
[
{
“id”: “test”,
“caption”: “Test”,
“children”: [
{
“command”: “test”,
“caption”: “Test”
}
]
}
]
test.py
import subprocess
import sublime, sublime_plugin
class TestCommand( sublime_plugin.WindowCommand ):
def run( self ): proc = subprocess.Popen( 'python', stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True ) out, err = proc.communicate()
To repro:
- Open two windows side by side
- Focus window on the left
- Run the plugin code using Menu Test -> test
- A python window should open then immediately close
- Observe the cursor and focus moving to the window on the right
Is this expected behaviour? I would expect the window on the left to maintain focus, since I used the left window’s menu to start the process.
Platform: Windows 10
Version: 3.2.1
Build: 3207