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:
parent
707e7c7250
commit
1e9ee0e665
12
docs/PLAN.md
12
docs/PLAN.md
|
|
@ -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
|
overflows ARG_MAX; paths relative to the root). Each `Symbol` carries
|
||||||
name / file / line / kind / scope.
|
name / file / line / kind / scope.
|
||||||
- Wired into the plugin: **Alt+R** "Go to Symbol (project)" opens a third
|
- Wired into the plugin: **Alt+R** "Go to Symbol (project)" opens a third
|
||||||
PaletteWidget of the project's symbols (label = `Scope::name`, hint =
|
PaletteWidget of the project's symbols. The label is
|
||||||
`kind file`). Activation opens the file via `MainWindow::openUrl` and
|
`Scope::name — kind file` — the name leads (so a name hit ranks first)
|
||||||
jumps the cursor to the symbol's line (ctags 1-based → cursor 0-based).
|
while the kind and file are both visible and filterable in the same query
|
||||||
Also in the M-x palette (`ollie:switch:symbol`) and reachable from a radial
|
(e.g. "method olliecommands"). Activation opens the file via
|
||||||
by objectName `ollie_goto_symbol`.
|
`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
|
## Build and test
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -559,19 +559,23 @@ void OllieView::showSymbolSwitcher()
|
||||||
// resolved against m_symbolSwitcherRoot on activation.
|
// resolved against m_symbolSwitcherRoot on activation.
|
||||||
item.id = kSymbolPrefix + s.file + QLatin1Char('\t') + QString::number(s.line);
|
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;
|
QString label = s.name;
|
||||||
if (!s.scope.isEmpty()) {
|
if (!s.scope.isEmpty()) {
|
||||||
label = s.scope + QStringLiteral("::") + s.name;
|
label = s.scope + QStringLiteral("::") + s.name;
|
||||||
}
|
}
|
||||||
item.label = label;
|
QString suffix = s.kind;
|
||||||
|
|
||||||
// Trailing hint: kind plus the file for provenance.
|
|
||||||
QString hint = s.kind;
|
|
||||||
if (!s.file.isEmpty()) {
|
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);
|
items.push_back(item);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue