def run(self, edit): """Called when the command is run.""" self.edit = edit cursor = self.view.sel()[0] word_region = self.view.word(cursor) word_text = self.view.substr(word_region) import_undefined_vars = utils.get_project_pref('import_undefined_vars', view=self.view) self.module_loader = ModuleLoader(self.view.file_name()) self.files = self.module_loader.get_file_list() words = [word_text] if cursor.empty() and import_undefined_vars: undef_vars = self.find_undefined_vars() if undef_vars: words = undef_vars for word in words: module = utils.best_fuzzy_match(self.files, word) self.view.run_command('require_insert_helper', {'args': { 'module': module, 'type': 'word' }})
def run(self, edit): """Called when the command is run.""" self.edit = edit cursor = self.view.sel()[0] word_region = self.view.word(cursor) word_text = self.view.substr(word_region) self.module_loader = ModuleLoader(self.view.file_name()) files = self.module_loader.get_file_list() module = utils.best_fuzzy_match(files, word_text) self.view.run_command('require_insert_helper', { 'args': { 'module': module, 'type': 'word' } })
def run(self, edit, command): """Called when the command is run.""" self.edit = edit # Simple Require Command if command is 'simple': # Must copy the core modules so modifying self.files # does not change the core_modules list self.files = list(core_modules) func = self.insert # Export Command else: self.files = [] self.exports = ['------ Select One or More Options ------'] self.selected_exports = [] func = self.show_exports self.module_loader = ModuleLoader(self.view.file_name()) self.files += self.module_loader.get_file_list() sublime.active_window().show_quick_panel( self.files, self.on_done_call_func(self.files, func))