为了理解我要达到的目的:在另一 View 中打印延迟的文本...
我正在尝试使此sublime text 3插件正常运行,我想使用run方法的传入参数来调用类的多个方法,如下所示:
# sample code, nothing real
class MyCommandClass(sublime_plugin.TextCommand):
myEdit = None
def run(self, edit):
self.myEdit = edit
# stuff
self.myMethod()
def myMethod(self):
# use self.myEdit ...
我稍后尝试在另一种方法上使用它,但是当我执行插件时,出现此错误:
ValueError: Edit objects may not be used after the TextCommand's run method has returned
据我了解,对edit对象的所有使用都必须在run命令返回之前进行。当我在玩
set_timeout
时,情况可能并非如此……那我该怎么办?提前致谢。
最佳答案
找到解决方案,将参数传递给另一个 View 并使用edit:
class MainCommand(sublime_plugin.WindowCommand):
def run(self):
newFile = self.window.new_file()
newFile.run_command("second",{ "arg" : "this is an argument"});
class SecondCommand(sublime_plugin.TextCommand):
def run(self, edit, argument):
# do stuff with argument
关于python - 运行Sublime Text 3插件时保存编辑,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/20466014/