Gerrnperl / outline-map

A visual, interactive outline map that combines the clarity of the outline with the intuitive overview of the minimap. Alternative Minimap.
https://marketplace.visualstudio.com/items?itemName=Gerrnperl.outline-map
MIT License
229 stars 18 forks source link

FR: Auto follow highlight nested items' parent nodes when not expanded #65

Open lethefrost opened 7 months ago

lethefrost commented 7 months ago

Is your feature request related to a problem? Please describe. Currently, if you set the outline map to auto follow the viewport, but the auto expand behavior is set to manual or cursor, you will encounter losing the highlight in the outline pane indicating the current viewport position/range from time to time.

There are two types of highlights: the cursor highlight, and the viewport range highlight. The plugin setting only affects the timing of these highlight (and corresponding expanding/collapsing of the tree nodes in the outline pane) get refreshed - whether it refreshes when scrolling (when set to viewport), or when the cursor position changes (cursor), or not refreshing at all if set to manual.

Now the range highlighting in the outline pane only highlights the elements that appear in the current viewport, i.e., those visible on the current screen, and does not simultaneously highlight their parent nodes in the tree along with it. Therefore, when you are reading code that includes a very long function body or class definition, or even just a multi-line variable (such as a dictionary, multiline string, or object literal), and you scroll to the middle part, you will only see the internal elements within your viewport, not the function header or the location where the identifier itself is defined.

Since you have not set these to automatically expand with the viewport, they all appear as collapsed child nodes in the outline window. Consequently, no range highlighting will be shown in the outline window! It can feel like you suddenly lose your bearings, unsure of where you are in the document.

Describe the solution you'd like

Therefore, I believe it is a good idea to also highlight the parent elements in the tree structure when displaying range highlights, to help locate the context of the viewport when all the currently visible elements are collapsed.

Describe alternatives you've considered For now, in order to always have a clear picture of where you are in the outline, you have to set expand following viewport as well.

Additional context N.A.

Thank you so much for this plugin! It's really helpful and better than the builtin one in most cases.