user2221343
user2221343

Reputation: 614

Sublime Text 3: Write text to output panel

I am trying to create a Sublime Text 3 plugin which writes output to an output panel in the current window. I have found a number of examples doing this using begin_edit and end_edit, which are no longer supported in ST3. To my understanding, ST3 requires that I define a TextCommand to support the editing action on my output panel. So far, what I have is this:

class SfprintCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.view.insert(edit, self.view.size(), 'hello')

class SfCommand(sublime_plugin.TextCommand):
    def run(self, edit):
        self.panel = self.view.window().create_output_panel('sf_st3_output')
        self.view.window().run_command('show_panel', { 'panel': 'output.sf_st3_output' })
        self.panel.run_command('sfprint');

I would expect that this should print the text "hello" in my output panel, but when I try to invoke this through the console (by running view.run_command('sf')), this displays the new panel but does not print any information to it. How can I write text to this panel?

Upvotes: 6

Views: 2078

Answers (1)

user2221343
user2221343

Reputation: 614

After restarting everything, the same code seems to be working now. My lesson learned: apparently it's best not too put too much faith into ST3's hot plugin reloading!

Upvotes: 4

Related Questions