diff --git a/src/SymbolPane/C/CtagsSymbolOutline.vala b/src/SymbolPane/C/CtagsSymbolOutline.vala index 92b540cde..888f572b3 100644 --- a/src/SymbolPane/C/CtagsSymbolOutline.vala +++ b/src/SymbolPane/C/CtagsSymbolOutline.vala @@ -275,10 +275,42 @@ public class Scratch.Services.CtagsSymbolOutline : Scratch.Services.SymbolOutlin destroy_root (root); root = new_root; + add_tooltips (store.root); return false; }); } + protected override void add_tooltips (Code.Widgets.SourceList.ExpandableItem root) { + foreach (var parent in root.children) { + if (parent is Code.Widgets.SourceList.ExpandableItem) { + add_tooltip ((Code.Widgets.SourceList.ExpandableItem) parent); + } + } + } + + private void add_tooltip (Code.Widgets.SourceList.ExpandableItem parent) { + if (parent is CtagsSymbol) { + var item = ((CtagsSymbol)parent); + var start = item.line; + var end = item.line; + // The type of a method is often on the previous line + if (item.symbol_type == SymbolType.METHOD) { + start = start > 0 ? start - 1 : start; + } + + item.tooltip = Markup.escape_text ("%s".printf ( + doc.get_slice ( + start, + 0, + end, + 0 + ) + )); + } + + add_tooltips (parent); + } + private void destroy_root (Code.Widgets.SourceList.ExpandableItem to_destroy) { var children = iterate_children (to_destroy); to_destroy.clear ();