docs: def set_editor(self, editor):
          """
          Sets the current editor. The widget display the structure of that
          editor.
  
          :param editor: CodeEdit
          """
          try:
              self._editor.cursorPositionChanged.disconnect(self.sync)
          except (AttributeError, TypeError, RuntimeError, ReferenceError):
              pass
          try:
              self._outline_mode.document_changed.disconnect(
                  self._on_changed)
          except (AttributeError, TypeError, RuntimeError, ReferenceError):
              pass
          try:
              self._folding_panel.trigger_state_changed.disconnect(
                  self._on_block_state_changed)
          except (AttributeError, TypeError, RuntimeError, ReferenceError):
              pass
          if editor:
              self._editor = weakref.proxy(editor)
          else:
              self._editor = None
  
          if editor is not None:
              editor.cursorPositionChanged.connect(self.sync)
              try:
                  self._folding_panel = weakref.proxy(
                      editor.panels.get(FoldingPanel))
              except KeyError:
                  pass
              else:
                  self._folding_panel.trigger_state_changed.connect(
                      self._on_block_state_changed)
              try:
                  analyser = editor.modes.get(OutlineMode)
              except KeyError:
                  self._outline_mode = None
              else:
                  self._outline_mode = weakref.proxy(analyser)
                  analyser.document_changed.connect(self._on_changed)
          self._on_changed()