My Sublime Text 3 Custom Package Dependencies Doesn't Saved Properly

I hope someone can help with this situation. So, I am learning to develop a Sublime Text 3 package for my own. But, a problem came earlier and I got stuck fast.

I have these 2 files inside my ST3 Packages folder:

CucumberTestingBundle/cucumber_testing_bundle.py (part of this file I copied from https://github.com/astrauka/TestRSpec/blob/master/test_rspec.py because I googled and found it can help to reload this file when saving dependency files)

import os
import sys
import sublime
import sublime_plugin

BASE_PATH = os.path.abspath(os.path.dirname(__file__))
CODE_DIRS = [
  "libs",
]
sys.path += [BASE_PATH] + [os.path.join(BASE_PATH, f) for f in CODE_DIRS]

class ReloadPlugin(sublime_plugin.EventListener):
  PACKAGE_NAME = 'CucumberTestingBundle'
  PLUGIN_RELOAD_TIME_MS = 200
  PLUGIN_PYTHON_FILE = os.path.join(PACKAGE_NAME, "cucumber_testing_bundle.py")

  def on_post_save(self, view):
    file_name = view.file_name()
    if not ReloadPlugin.PACKAGE_NAME in file_name: return
    if ReloadPlugin.PLUGIN_PYTHON_FILE in file_name: return

    original_file_name = view.file_name()
    plugin_python_file = os.path.join(sublime.packages_path(), ReloadPlugin.PLUGIN_PYTHON_FILE)
    if not os.path.isfile(plugin_python_file): return

    def _open_original_file():
      view.window().open_file(original_file_name)

    plugin_view = view.window().open_file(plugin_python_file)
    print("save", plugin_view.file_name())
    plugin_view.run_command("save")
    sublime.set_timeout_async(_open_original_file, self.PLUGIN_RELOAD_TIME_MS)

from libs.panels import Panel

class RunCucumberCommand(sublime_plugin.TextCommand):
  def run(self, edit):
    panel = Panel(self.view.window(), edit, sublime.load_settings("Preferences.sublime-settings").get("panel_settings"))
    panel.write("running RunCucumberCommand")
    print(panel.display_panel())

CucumberTestingBundle/libs/panel.rb

class Panel(object):
  NAME_PREFIX = "ctb"

  def __init__(self, window, edit, settings = {}):
    print("SOMETHING")
    self.window = window
    self.edit = edit
    self.panel = self._prepare_panel(settings)

  def _prepare_panel(self, settings = {}):
    panel = self.window.get_output_panel(Panel.NAME_PREFIX)

    for key, value in settings.items():
      panel.settings().set(key, value)

    return panel

  def _panel_name(self):
    return "output.{0}".format(Panel.NAME_PREFIX)

  def display_panel(self):
    self.window.run_command("show_panel", {"panel": self._panel_name()})
    return "S"

  def write(self, text):
    self.panel.insert(self.edit, 0, "{0}\n".format(text))

I used the print("SOMETHING") in __init__ method and return "S" in display_panel method as debugging helper. As I run view.run_command("run_cucumber") in ST3's console it printed "SOMETHING" and "S" in separate lines, it should be. But when I changed that SOMETHING or S with other string and run the command again, it still prints "SOMETHING" and "S". Could someone help me and give the explanation why is this happening? I couldn't find the problem yet.

Thanks

EDITED

P.S.: Dependencies run perfectly if I restart my ST3

pythonsublimetext3sublime-text-plugin

Answers

comments powered by Disqus