'Bind editor instance'

def set_current_editor(self, editor, fname, update):

    editor_id = editor.get_document_id()
    if (editor_id in list(self.editor_ids.values())):
        item = self.editor_items[editor_id]
        if (not self.freeze):
            self.scrollToItem(item)
            self.root_item_selected(item)
            self.__hide_or_show_root_items(item)
        if update:
            self.save_expanded_state()
            tree_cache = self.editor_tree_cache[editor_id]
            self.populate_branch(editor, item, tree_cache)
            self.restore_expanded_state()
    else:
        root_item = FileRootItem(fname, self)
        root_item.set_text(fullpath=self.show_fullpath)
        tree_cache = self.populate_branch(editor, root_item)
        self.__sort_toplevel_items()
        self.__hide_or_show_root_items(root_item)
        self.root_item_selected(root_item)
        self.editor_items[editor_id] = root_item
        self.editor_tree_cache[editor_id] = tree_cache
        self.resizeColumnToContents(0)
    if (editor not in self.editor_ids):
        self.editor_ids[editor] = editor_id
    self.current_editor = editor
