def on_load(self, view):
if view.settings().get("_anf_new", False):
absolute_file_path = view.file_name()
if absolute_file_path is None:
return
file_name = self.get_basename(absolute_file_path)
_, full_extension = os.path.splitext(file_name)
if len(full_extension) == 0:
extension = file_name
else:
extension = full_extension[1:]
settings = get_settings(view)
if extension in settings.get(FILE_TEMPLATES_SETTING):
template = settings.get(FILE_TEMPLATES_SETTING)[extension]
if type(template) == list:
if len(template) == 1:
view.run_command("insert_snippet", {"contents": self.get_snippet_from_file(template[0])})
else:
entries = list(map(self.get_basename, template))
self.entries = list(map(self.expand_path, template))
self.view = view
sublime.set_timeout(lambda: view.window().show_quick_panel(entries, self.quick_panel_selection), 10)
else:
view.run_command("insert_snippet", {"contents": template})
view.settings().set("_anf_new", "")
new_file_command.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录