From 88ca9740bf88aa74c611583d4599d5d2195f3b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mart=C3=ADn=20Lucas=20Golini?= Date: Thu, 30 Mar 2023 01:09:34 -0300 Subject: [PATCH] ecode: Fixed a crash in doc search controller. --- src/tools/ecode/docsearchcontroller.cpp | 11 ++++++++--- src/tools/ecode/plugins/formatter/formatterplugin.cpp | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/tools/ecode/docsearchcontroller.cpp b/src/tools/ecode/docsearchcontroller.cpp index d0da6120c..cef4e4fa6 100644 --- a/src/tools/ecode/docsearchcontroller.cpp +++ b/src/tools/ecode/docsearchcontroller.cpp @@ -357,9 +357,14 @@ void DocSearchController::hideSearchBar() { void DocSearchController::onCodeEditorFocusChange( UICodeEditor* editor ) { if ( mSearchState.editor && mSearchState.editor != editor ) { - auto word = mSearchState.editor->getHighlightWord(); - mSearchState.editor->setHighlightWord( { "" } ); - mSearchState.editor->setHighlightTextRange( TextRange() ); + TextSearchParams word; + if ( mEditorSplitter->editorExists( mSearchState.editor ) ) { + word = mSearchState.editor->getHighlightWord(); + mSearchState.editor->setHighlightWord( { "" } ); + mSearchState.editor->setHighlightTextRange( TextRange() ); + } else { + mSearchState.editor = nullptr; + } mSearchState.text = ""; mSearchState.range = TextRange(); if ( editor ) { diff --git a/src/tools/ecode/plugins/formatter/formatterplugin.cpp b/src/tools/ecode/plugins/formatter/formatterplugin.cpp index ad07beb27..bab9f1956 100644 --- a/src/tools/ecode/plugins/formatter/formatterplugin.cpp +++ b/src/tools/ecode/plugins/formatter/formatterplugin.cpp @@ -275,6 +275,7 @@ bool FormatterPlugin::onCreateContextMenu( UICodeEditor* editor, UIPopUpMenu* me !supportsLSPFormatter( editor->getDocumentRef() ) ) return false; + menu->addSeparator(); menu->add( editor->getUISceneNode()->i18n( "formatter-format-document", "Format Document" ), nullptr, KeyBindings::keybindFormat( mKeyBindings["format-doc"] ) ) ->setId( "format-doc" );