diff --git a/src/eepp/ui/uicodeeditor.cpp b/src/eepp/ui/uicodeeditor.cpp index d18bbda0a..de6f0fde7 100644 --- a/src/eepp/ui/uicodeeditor.cpp +++ b/src/eepp/ui/uicodeeditor.cpp @@ -1496,7 +1496,7 @@ void UICodeEditor::updateScrollBar() { void UICodeEditor::goToLine( const TextPosition& position, bool centered, bool forceExactPosition, bool scrollX ) { mDoc->setSelection( position ); - scrollTo( mDoc->getSelection(), centered, forceExactPosition, scrollX ); + scrollTo( mDoc->getSelection().start(), centered, forceExactPosition, scrollX ); } bool UICodeEditor::getAutoCloseBrackets() const { @@ -1568,13 +1568,14 @@ void UICodeEditor::copyFilePath( bool copyPosition ) { } void UICodeEditor::scrollToCursor( bool centered ) { - scrollTo( mDoc->getSelection(), centered ); + scrollTo( mDoc->getSelection().start(), centered ); } void UICodeEditor::updateEditor() { mDoc->setPageSize( getVisibleLinesCount() ); if ( mDirtyScroll && mDoc->getActiveClient() == this ) - scrollTo( mDoc->getSelection() ); + scrollTo( mDoc->getSelection().start() ); + updateScrollBar(); mDirtyEditor = false; mDirtyScroll = false; diff --git a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp index b81d0f68b..a745fa069 100644 --- a/src/tools/ecode/plugins/lsp/lspclientplugin.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientplugin.cpp @@ -536,9 +536,18 @@ void LSPClientPlugin::createCodeActionsView( UICodeEditor* editor, } else { casEmpty = false; auto casN( cas ); - LSPCodeAction action{ mQuickFix.title, mQuickFix.kind, {}, mQuickFix.edit, {}, - mQuickFix.isPreferred }; - casN.insert( casN.begin(), action ); + bool foundRepeated = false; + for ( const auto& c : casN ) { + if ( mQuickFix.title == c.title ) { + foundRepeated = true; + break; + } + } + if ( !foundRepeated ) { + LSPCodeAction action{ mQuickFix.title, mQuickFix.kind, {}, mQuickFix.edit, {}, + mQuickFix.isPreferred }; + casN.insert( casN.begin(), action ); + } model = LSPCodeActionModel::create( mManager->getSplitter()->getUISceneNode(), casN ); } @@ -1009,14 +1018,12 @@ void LSPClientPlugin::processDiagnosticsCodeAction( const PluginMessage& msg ) { } void LSPClientPlugin::codeAction( UICodeEditor* editor ) { - // It seems that we don't require this hack anymore - // TODO: Check if this is needed in some situation - /*json j; + json j; j["uri"] = editor->getDocument().getURI().toString(); j["pos"] = editor->getDocument().getSelection().start().toString(); mQuickFix = {}; auto req = mManager->sendRequest( PluginMessageType::DiagnosticsCodeAction, - PluginMessageFormat::JSON, &j );*/ + PluginMessageFormat::JSON, &j ); json j2; j2["uri"] = editor->getDocument().getURI().toString(); diff --git a/src/tools/ecode/plugins/lsp/lspclientserver.cpp b/src/tools/ecode/plugins/lsp/lspclientserver.cpp index 6bdd1c245..164ccf712 100644 --- a/src/tools/ecode/plugins/lsp/lspclientserver.cpp +++ b/src/tools/ecode/plugins/lsp/lspclientserver.cpp @@ -2048,7 +2048,7 @@ LSPClientServer::documentFormatting( const URI& document, const json& options, LSPClientServer::LSPRequestHandle LSPClientServer::documentRangeFormatting( const URI& document, const TextRange& range, const json& options, const JsonReplyHandler& h ) { - auto params = textDocumentOptions( document, options, range ); + auto params = textDocumentOptions( document, options, range.normalized() ); return send( newRequest( "textDocument/rangeFormatting", params ), h ); }