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

在Python类中 region表现不符合预期 #56

Closed Yuelioi closed 2 months ago

Yuelioi commented 11 months ago

Bug 描述

当在python class中使用region时, 无法覆盖到最后一个函数, 如果region包含最后一个函数,则该region会失效

20240102-06064827.png

joshua-dean commented 4 months ago

+1 I have encountered the same issue - any region containing the last function in a class definition doesn't work correctly, getting placed at the end of the outline. This occurs regardless of the "Start Region" and "End Region" settings (I tried both # region and #region).

Having any statement after the "End Region" does show the outline correctly. image

Setup:

joshua-dean commented 3 months ago

I think this is because the DocumentSymbol for the class defines the end range as the last source line, which doesn't include the last # endregion.

I will try to see if there is an easy way to handle this - I am still familiarizing myself with the codebase.

joshua-dean commented 3 months ago

I have a fix here: https://github.com/joshua-dean/outline-map/commit/855f89599fccebc72b7350d53b1b5d4b7f0137a7

When calling reconstructTree, if the sibling is a "region", it only checks the start, not the end.

Result: image

I am not sure if this is the best property to check. It doesn't seem to create any other issues.

I think this is only an issue with languages like python that use indentation for scope - languages like JavaScript have closing brackets that would ensure the region is contained. We might want to query the language for checks like this.

Are there any linting/formatting/testing I should complete, or do you think I'm good to open a PR?

joshua-dean commented 2 months ago

@Yuelioi The 1.4.1 release fixed this for me. Is this issue also solved for you?

Yuelioi commented 2 months ago

@Yuelioi The 1.4.1 release fixed this for me. Is this issue also solved for you?

Yes, it works well now