Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Yuelioi opened this issue Jan 1, 2024 · 5 comments
Closed

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

Yuelioi opened this issue Jan 1, 2024 · 5 comments

Comments

@Yuelioi
Copy link

Yuelioi commented Jan 1, 2024

Bug 描述

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

20240102-06064827.png

  • windows
  • vscode 1.85.1
@joshua-dean
Copy link
Contributor

+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:

  • Ubuntu 22.04.2 LTS
  • vscode 1.90.1 x64
  • Outline Map v1.4.0

@joshua-dean
Copy link
Contributor

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
Copy link
Contributor

I have a fix here: joshua-dean@855f895

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
Copy link
Contributor

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

@Yuelioi
Copy link
Author

Yuelioi commented Sep 17, 2024

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

Yes, it works well now

@Yuelioi Yuelioi closed this as completed Sep 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants