From 1395fef635ca884ef286e3484639087c6f103ad5 Mon Sep 17 00:00:00 2001 From: Eran Ifrah Date: Thu, 30 Dec 2021 19:14:56 +0200 Subject: [PATCH] - LSP outline dialog: center the editor around the selected option - Open resource dialog: center the resource around the selected entry --- LanguageServer/LSPOutlineViewDlg.cpp | 1 + LiteEditor/findusagetab.cpp | 4 +--- Plugin/open_resource_dialog.cpp | 11 +++-------- 3 files changed, 5 insertions(+), 11 deletions(-) diff --git a/LanguageServer/LSPOutlineViewDlg.cpp b/LanguageServer/LSPOutlineViewDlg.cpp index ec0f1be0e1..fd0a5c7156 100644 --- a/LanguageServer/LSPOutlineViewDlg.cpp +++ b/LanguageServer/LSPOutlineViewDlg.cpp @@ -256,6 +256,7 @@ void LSPOutlineViewDlg::DoSelectionActivate() int position = active_editor->PosFromLine(sci_line); // start of line position += loc.GetRange().GetStart().GetCharacter(); // add the column active_editor->SetCaretAt(position); + active_editor->CenterLine(sci_line); } else { active_editor->SelectRange(loc.GetRange()); active_editor->CenterLinePreserveSelection(sci_line); diff --git a/LiteEditor/findusagetab.cpp b/LiteEditor/findusagetab.cpp index 06b3c3111d..14ac3638b1 100644 --- a/LiteEditor/findusagetab.cpp +++ b/LiteEditor/findusagetab.cpp @@ -215,9 +215,7 @@ void FindUsageTab::OnItemActivated(wxTreeEvent& event) if(!item_data) { // header entry DoExpandItem(event.GetItem()); - if(m_ctrl->IsExpanded(event.GetItem())) { - m_ctrl->Collapse(event.GetItem()); - } else { + if(!m_ctrl->IsExpanded(event.GetItem())) { m_ctrl->Expand(event.GetItem()); } return; diff --git a/Plugin/open_resource_dialog.cpp b/Plugin/open_resource_dialog.cpp index 0573edccd6..10179e1dd3 100644 --- a/Plugin/open_resource_dialog.cpp +++ b/Plugin/open_resource_dialog.cpp @@ -308,14 +308,9 @@ void OpenResourceDialog::OpenSelection(const OpenResourceDialogItemData& selecti return; clDEBUG() << "Opening editor:" << selection.m_file << ":" << selection.m_line << ":" << selection.m_column << endl; - IEditor* editor = clGetManager()->OpenFile(selection.m_file, wxEmptyString, selection.m_line - 1); - if(editor) { - if(!selection.m_name.IsEmpty() && !selection.m_pattern.IsEmpty()) { - editor->FindAndSelectV(selection.m_pattern, selection.m_name); - } else if(selection.m_column != wxNOT_FOUND) { - editor->CenterLine(selection.m_line - 1, selection.m_column); - } - } + + auto callback = [=](IEditor* editor) { editor->CenterLine(selection.m_line - 1, selection.m_column); }; + clGetManager()->OpenFileAndAsyncExecute(selection.m_file, std::move(callback)); } void OpenResourceDialog::OnKeyDown(wxKeyEvent& event)