Go-to-Symbol: fold kind+file into the visible label

The delegate renders only the label, so the symbol switcher's group
(kind+file) was invisible. Fold it into the label as
'Scope::name  —  kind file': the name leads so a name hit still ranks
first, while the kind and file become visible and filterable in the same
fuzzy query.
This commit is contained in:
Levi Neely 2026-10-07 20:53:29 +02:00
parent 707e7c7250
commit 1e9ee0e665
2 changed files with 18 additions and 12 deletions

View File

@ -217,11 +217,13 @@ Therefore the palette is replaced, not extended, and the replacement is built on
overflows ARG_MAX; paths relative to the root). Each `Symbol` carries
name / file / line / kind / scope.
- Wired into the plugin: **Alt+R** "Go to Symbol (project)" opens a third
PaletteWidget of the project's symbols (label = `Scope::name`, hint =
`kind file`). Activation opens the file via `MainWindow::openUrl` and
jumps the cursor to the symbol's line (ctags 1-based → cursor 0-based).
Also in the M-x palette (`ollie:switch:symbol`) and reachable from a radial
by objectName `ollie_goto_symbol`.
PaletteWidget of the project's symbols. The label is
`Scope::name — kind file` — the name leads (so a name hit ranks first)
while the kind and file are both visible and filterable in the same query
(e.g. "method olliecommands"). Activation opens the file via
`MainWindow::openUrl` and jumps the cursor to the symbol's line (ctags
1-based → cursor 0-based). Also in the M-x palette (`ollie:switch:symbol`)
and reachable from a radial by objectName `ollie_goto_symbol`.
## Build and test

View File

@ -559,19 +559,23 @@ void OllieView::showSymbolSwitcher()
// resolved against m_symbolSwitcherRoot on activation.
item.id = kSymbolPrefix + s.file + QLatin1Char('\t') + QString::number(s.line);
// Label: scope-qualified name so "Class::method" matches naturally.
// Label: scope-qualified name, then kind + file as visible provenance.
// The delegate renders only the label and FuzzyRanker scores against it,
// so folding provenance in keeps it both visible and filterable (e.g.
// "method olliecommands" narrows by name and file at once). The name
// leads, so a name hit scores highest and ranks first.
QString label = s.name;
if (!s.scope.isEmpty()) {
label = s.scope + QStringLiteral("::") + s.name;
}
item.label = label;
// Trailing hint: kind plus the file for provenance.
QString hint = s.kind;
QString suffix = s.kind;
if (!s.file.isEmpty()) {
hint = hint.isEmpty() ? s.file : (s.kind + QStringLiteral(" ") + s.file);
suffix = suffix.isEmpty() ? s.file : (s.kind + QStringLiteral(" ") + s.file);
}
item.group = hint;
if (!suffix.isEmpty()) {
label += QStringLiteral(" — ") + suffix;
}
item.label = label;
items.push_back(item);
}