docs: def add_code_edit(self, code_edit, name=None):
          """
          Adds a code edit tab, sets its text as the editor.file.name and
          sets it as the active tab.
  
          The widget is only added if there is no other editor tab open with the
          same filename, else the already open tab is set as current.
  
          If the widget file path is empty, i.e. this is a new document that has
          not been saved to disk, you may provided a formatted string
          such as 'New document %d.txt' for the document name. The int format
          will be automatically replaced by the number of new documents
          (e.g. 'New document 1.txt' then 'New document 2.txt' and so on).
          If you prefer to use your own code to manage the file names, just
          ensure that the names are unique.
  
          :param code_edit: The code editor widget tab to append
          :type code_edit: pyqode.core.api.CodeEdit
  
          :param name: Name of the tab. Will use code_edit.file.name if None is
              supplied. Default is None. If this is a new document, you should
              either pass a unique name or a formatted string (with a '%d'
              format)
          :return: Tab index
          """
          # new empty editor widget (no path set)
          if code_edit.file.path == '':
              cnt = 0
              for i in range(self.count()):
                  tab = self.widget(i)
                  if tab.file.path.startswith(name[:name.find('%')]):
                      cnt += 1
              name %= (cnt + 1)
              code_edit.file._path = name
          index = self.index_from_filename(code_edit.file.path)
          if index != -1:
              # already open, just show it
              self.setCurrentIndex(index)
              # no need to keep this instance
              self._del_code_edit(code_edit)
              return -1
          self._ensure_unique_name(code_edit, name)
          index = self.addTab(code_edit, code_edit.file.icon,
                              code_edit._tab_name)
          self.setCurrentIndex(index)
          self.setTabText(index, code_edit._tab_name)
          try:
              code_edit.setFocus()
          except TypeError:
              # PySide
              code_edit.setFocus()
          try:
              file_watcher = code_edit.modes.get(FileWatcherMode)
          except (KeyError, AttributeError):
              # not installed
              pass
          else:
              file_watcher.file_deleted.connect(self._on_file_deleted)
          return index