我正在尝试编写一个插件,该插件将在常规选项卡而不是新窗口中打开首选项。这是我所拥有的:
import sublime
import sublime_plugin
from os import path
class OpenPreferencesCommand(sublime_plugin.TextCommand):
def run(self, edit):
# Open user preferences file in the 1st tab
filepath1 = path.normpath(path.join(__file__, '..', 'Preferences.sublime-settings'))
self.view.window().open_file(filepath1)
# Open default preferences file in the 2nd tab. Doesn't work
filepath2 = path.normpath(path.join(__file__, '../../Default', 'Preferences.sublime-settings'))
self.view.window().open_file(filepath2)
如您所见,它不适用于默认首选项文件(即打包的文件)。看来我需要使用sublime.decode_value
之类的
sublime.decode_value(sublime.load_resource('Packages/Default/Preferences.sublime-settings'))
但我不知道确切的方法。