Skip to content

Commit

Permalink
outline dialog: minor fix: when opening a C++ file, display the full …
Browse files Browse the repository at this point in the history
…function name
  • Loading branch information
eranif committed Dec 6, 2021
1 parent a3685b1 commit 5f885a0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
13 changes: 10 additions & 3 deletions LanguageServer/LSPOutlineViewDlg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ LSPOutlineViewDlg::LSPOutlineViewDlg(wxWindow* parent, const vector<SymbolInform
: LSPOutlineViewDlgBase(parent)
, m_symbols(symbols)
{
clSetDialogBestSizeAndPosition(this);
CallAfter(&LSPOutlineViewDlg::DoInitialise);
}

LSPOutlineViewDlg::~LSPOutlineViewDlg() {}

void LSPOutlineViewDlg::DoInitialise()
{
m_dvTreeCtrll->Begin();
m_dvTreeCtrll->SetScrollToBottom(false);

// build the tree
Expand Down Expand Up @@ -115,15 +124,13 @@ LSPOutlineViewDlg::LSPOutlineViewDlg(wxWindow* parent, const vector<SymbolInform
}
m_dvTreeCtrll->AddLine(builder.GetString(), false, (wxUIntPtr)&si);
}
clSetDialogBestSizeAndPosition(this);
if(!m_dvTreeCtrll->IsEmpty()) {
m_dvTreeCtrll->SelectRow(0);
}
m_dvTreeCtrll->Commit();
m_textCtrlFilter->CallAfter(&wxTextCtrl::SetFocus);
}

LSPOutlineViewDlg::~LSPOutlineViewDlg() {}

void LSPOutlineViewDlg::OnEnter(wxCommandEvent& event)
{
wxUnusedVar(event);
Expand Down
1 change: 1 addition & 0 deletions LanguageServer/LSPOutlineViewDlg.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class LSPOutlineViewDlg : public LSPOutlineViewDlgBase
void DoSelectionActivate();
void DoFindNext();
void DoFindPrev();
void DoInitialise();

public:
LSPOutlineViewDlg(wxWindow* parent, const vector<SymbolInformation>& symbols);
Expand Down
17 changes: 12 additions & 5 deletions ctagsd/lib/ProtocolHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,12 @@ void ProtocolHandler::on_document_symbol(unique_ptr<JSON>&& msg, Channel& channe
auto response = root.toElement();
auto result = build_result(response, id, cJSON_Array);

wxStringSet_t containers_seen;
for(const TagEntry& tag : tags) {
if(tag.IsContainer()) {
containers_seen.insert(tag.GetName());
}

LSP::SymbolInformation si;
LSP::Location loc;
LSP::Range range;
Expand All @@ -979,13 +984,15 @@ void ProtocolHandler::on_document_symbol(unique_ptr<JSON>&& msg, Channel& channe
loc.SetPath(filepath_uri);

si.SetKind(get_symbol_kind(tag));
si.SetContainerName(tag.GetScope());

if(tag.GetParent().empty()) {
si.SetName(tag.GetPath() + tag.GetSignature());
} else {
if(containers_seen.count(tag.GetParent())) {
si.SetContainerName(tag.GetParent());
si.SetName(tag.GetDisplayName());
} else {
// don't bother adding parent that we did not
// see until this point
si.SetName(tag.GetFullDisplayName());
}

si.SetLocation(loc);
result.arrayAppend(si.ToJSON(wxEmptyString));
}
Expand Down

0 comments on commit 5f885a0

Please sign in to comment.