# Buggy code
def create_new_editor(
    self, fname, enc, txt, set_current, new=False, cloned_from=None, add_where="end"
):
    """
    Create a new editor instance
    Returns finfo object (instead of editor as in previous releases)
    """
    editor = codeeditor.CodeEditor(self)
    editor.go_to_definition.connect(
        lambda fname, line, column: self.sig_go_to_definition.emit(fname, line, column)
    )

    finfo = FileInfo(fname, enc, editor, new, self.threadmanager)

    self.add_to_data(finfo, set_current, add_where)
    finfo.send_to_help.connect(self.send_to_help)
    finfo.todo_results_changed.connect(lambda: self.todo_results_changed.emit())
    finfo.edit_goto.connect(
        lambda fname, lineno, name: self.edit_goto.emit(fname, lineno, name)
    )
    finfo.sig_save_bookmarks.connect(
        lambda s1, s2: self.sig_save_bookmarks.emit(s1, s2)
    )
    editor.sig_run_selection.connect(self.run_selection)
    editor.sig_run_cell.connect(self.run_cell)
    editor.sig_run_cell_and_advance.connect(self.run_cell_and_advance)
    editor.sig_re_run_last_cell.connect(self.re_run_last_cell)
    editor.sig_new_file.connect(self.sig_new_file.emit)
    editor.sig_breakpoints_saved.connect(self.sig_breakpoints_saved)
    language = get_file_language(fname, txt)
    editor.setup_editor(
        linenumbers=self.linenumbers_enabled,
        show_blanks=self.blanks_enabled,
        scroll_past_end=self.scrollpastend_enabled,
        edge_line=self.edgeline_enabled,
        edge_line_columns=self.edgeline_columns,
        language=language,
        markers=self.has_markers(),
        font=self.default_font,
        color_scheme=self.color_scheme,
        wrap=self.wrap_enabled,
        tab_mode=self.tabmode_enabled,
        intelligent_backspace=self.intelligent_backspace_enabled,
        highlight_current_line=self.highlight_current_line_enabled,
        highlight_current_cell=self.highlight_current_cell_enabled,
        occurrence_highlighting=self.occurrence_highlighting_enabled,
        occurrence_timeout=self.occurrence_highlighting_timeout,
        codecompletion_auto=self.codecompletion_auto_enabled,
        codecompletion_case=self.codecompletion_case_enabled,
        codecompletion_enter=self.codecompletion_enter_enabled,
        calltips=self.calltips_enabled,
        go_to_definition=self.go_to_definition_enabled,
        close_parentheses=self.close_parentheses_enabled,
        close_quotes=self.close_quotes_enabled,
        add_colons=self.add_colons_enabled,
        auto_unindent=self.auto_unindent_enabled,
        indent_chars=self.indent_chars,
        tab_stop_width_spaces=self.tab_stop_width_spaces,
        cloned_from=cloned_from,
        filename=fname,
        show_class_func_dropdown=self.show_class_func_dropdown,
        indent_guides=self.indent_guides,
    )
    if cloned_from is None:
        editor.set_text(txt)
        editor.document().setModified(False)
    editor.document().changed_since_autosave = False
    finfo.text_changed_at.connect(
        lambda fname, position: self.text_changed_at.emit(fname, position)
    )
    editor.sig_cursor_position_changed.connect(self.editor_cursor_position_changed)
    editor.textChanged.connect(self.start_stop_analysis_timer)
    editor.sig_perform_lsp_request.connect(
        lambda lang, method, params: self.perform_lsp_request.emit(lang, method, params)
    )
    editor.modificationChanged.connect(
        lambda state: self.modification_changed(state, editor_id=id(editor))
    )
    editor.focus_in.connect(self.focus_changed)
    editor.zoom_in.connect(lambda: self.zoom_in.emit())
    editor.zoom_out.connect(lambda: self.zoom_out.emit())
    editor.zoom_reset.connect(lambda: self.zoom_reset.emit())
    editor.sig_eol_chars_changed.connect(
        lambda eol_chars: self.refresh_eol_chars(eol_chars)
    )

    self.find_widget.set_editor(editor)

    self.refresh_file_dependent_actions.emit()
    self.modification_changed(index=self.data.index(finfo))

    # Needs to reset the highlighting on startup in case the PygmentsSH
    # is in use
    editor.run_pygments_highlighter()
    options = {
        "language": editor.language,
        "filename": editor.filename,
        "codeeditor": editor,
    }
    self.sig_open_file.emit(options)
    if self.get_stack_index() == 0:
        self.current_changed(0)

    return finfo


# Traceback (AttributeError)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\lsp\client.py", line 230, in on_msg_received
handler(resp['result'], req_id)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\lsp\providers\document.py", line 117, in process_document_completion
LSPRequestTypes.DOCUMENT_COMPLETION, {'params': response})
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\widgets\codeeditor.py", line 690, in handle_response
handler(params)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\widgets\codeeditor.py", line 790, in process_completion
self.completion_widget.show_list(completion_list, position)
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\widgets\base.py", line 159, in show_list
self.update_current()
File "C:\Users\C. A. M. Gerlach\Documents\dev\SpyderDev\spyder\spyder\plugins\editor\widgets\base.py", line 222, in update_current
completion_label = completion.lower()
AttributeError: 'dict' object has no attribute 'lower'

# Fixed code
def create_new_editor(
    self, fname, enc, txt, set_current, new=False, cloned_from=None, add_where="end"
):
    """
    Create a new editor instance
    Returns finfo object (instead of editor as in previous releases)
    """
    editor = codeeditor.CodeEditor(self)
    editor.go_to_definition.connect(
        lambda fname, line, column: self.sig_go_to_definition.emit(fname, line, column)
    )

    finfo = FileInfo(fname, enc, editor, new, self.threadmanager)

    self.add_to_data(finfo, set_current, add_where)
    finfo.send_to_help.connect(self.send_to_help)
    finfo.todo_results_changed.connect(lambda: self.todo_results_changed.emit())
    finfo.edit_goto.connect(
        lambda fname, lineno, name: self.edit_goto.emit(fname, lineno, name)
    )
    finfo.sig_save_bookmarks.connect(
        lambda s1, s2: self.sig_save_bookmarks.emit(s1, s2)
    )
    editor.sig_run_selection.connect(self.run_selection)
    editor.sig_run_cell.connect(self.run_cell)
    editor.sig_run_cell_and_advance.connect(self.run_cell_and_advance)
    editor.sig_re_run_last_cell.connect(self.re_run_last_cell)
    editor.sig_new_file.connect(self.sig_new_file.emit)
    editor.sig_breakpoints_saved.connect(self.sig_breakpoints_saved)
    language = get_file_language(fname, txt)
    editor.setup_editor(
        linenumbers=self.linenumbers_enabled,
        show_blanks=self.blanks_enabled,
        scroll_past_end=self.scrollpastend_enabled,
        edge_line=self.edgeline_enabled,
        edge_line_columns=self.edgeline_columns,
        language=language,
        markers=self.has_markers(),
        font=self.default_font,
        color_scheme=self.color_scheme,
        wrap=self.wrap_enabled,
        tab_mode=self.tabmode_enabled,
        intelligent_backspace=self.intelligent_backspace_enabled,
        highlight_current_line=self.highlight_current_line_enabled,
        highlight_current_cell=self.highlight_current_cell_enabled,
        occurrence_highlighting=self.occurrence_highlighting_enabled,
        occurrence_timeout=self.occurrence_highlighting_timeout,
        close_parentheses=self.close_parentheses_enabled,
        close_quotes=self.close_quotes_enabled,
        add_colons=self.add_colons_enabled,
        auto_unindent=self.auto_unindent_enabled,
        indent_chars=self.indent_chars,
        tab_stop_width_spaces=self.tab_stop_width_spaces,
        cloned_from=cloned_from,
        filename=fname,
        show_class_func_dropdown=self.show_class_func_dropdown,
        indent_guides=self.indent_guides,
    )
    if cloned_from is None:
        editor.set_text(txt)
        editor.document().setModified(False)
    editor.document().changed_since_autosave = False
    finfo.text_changed_at.connect(
        lambda fname, position: self.text_changed_at.emit(fname, position)
    )
    editor.sig_cursor_position_changed.connect(self.editor_cursor_position_changed)
    editor.textChanged.connect(self.start_stop_analysis_timer)
    editor.sig_perform_lsp_request.connect(
        lambda lang, method, params: self.perform_lsp_request.emit(lang, method, params)
    )
    editor.modificationChanged.connect(
        lambda state: self.modification_changed(state, editor_id=id(editor))
    )
    editor.focus_in.connect(self.focus_changed)
    editor.zoom_in.connect(lambda: self.zoom_in.emit())
    editor.zoom_out.connect(lambda: self.zoom_out.emit())
    editor.zoom_reset.connect(lambda: self.zoom_reset.emit())
    editor.sig_eol_chars_changed.connect(
        lambda eol_chars: self.refresh_eol_chars(eol_chars)
    )

    self.find_widget.set_editor(editor)

    self.refresh_file_dependent_actions.emit()
    self.modification_changed(index=self.data.index(finfo))

    # Needs to reset the highlighting on startup in case the PygmentsSH
    # is in use
    editor.run_pygments_highlighter()
    options = {
        "language": editor.language,
        "filename": editor.filename,
        "codeeditor": editor,
    }
    self.sig_open_file.emit(options)
    if self.get_stack_index() == 0:
        self.current_changed(0)

    return finfo