为了理解我想要实现的目标:在另一个 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:在 TextCommand 的运行方法返回后可能无法使用编辑对象
据我所知,所有对编辑对象的使用都必须在运行命令返回之前进行。当我使用 set_timeout
时,情况可能并非如此...那我能做什么呢?
提前致谢。
最佳答案
找到解决方案,将参数传递给另一个 View 并使用编辑:
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/