Skip to content

Commit

Permalink
- LSP outline dialog: center the editor around the selected option
Browse files Browse the repository at this point in the history
- Open resource dialog: center the resource around the selected entry
  • Loading branch information
eranif committed Dec 30, 2021
1 parent c4bb403 commit 1395fef
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 11 deletions.
1 change: 1 addition & 0 deletions LanguageServer/LSPOutlineViewDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions LiteEditor/findusagetab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
11 changes: 3 additions & 8 deletions Plugin/open_resource_dialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1395fef

Please sign in to comment.