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

PyCharm & python code regions: # Region does not work #56

Open
schittli opened this issue Jul 27, 2023 · 5 comments
Open

PyCharm & python code regions: # Region does not work #56

schittli opened this issue Jul 27, 2023 · 5 comments
Labels
bug Something isn't working enhancement New feature or request question Further information is requested

Comments

@schittli
Copy link

schittli commented Jul 27, 2023

Good afternoon

I have found another, probably small issue in PyCharm for Python source files:

If a Region is declared with upper case char (# Region Init-Section … # Endregion Init-Section), then:
✔️ Better Highlights recognizes the region
❌ PyCharm does not recognize the region and, therefore, does not allow to fold it 😢

If a Region is declared with lower case char (# region Init-Section … # endregion Init-Section), then:
️❌ Better Highlights does not recognize the region
✔️ PyCharm perfectly recognize the region and allows to fold it 😃

I propose that:
a) Users can configure if Better Highlights recognizes Region declarations case sensitive / insensitive
b) That Better Highlights always recognizes Region declarations case insensitive
b) or: that Users can define regular expressions to recognize start and end of regions

Thanks a lot, kind regards,
Thomas

@schittli schittli changed the title Python & code regions: Is case sensitive / # Region does not work Python & python code regions: Is case sensitive / # Region does not work Jul 27, 2023
@schittli schittli changed the title Python & python code regions: Is case sensitive / # Region does not work PyCharm & python code regions: Is case sensitive / # Region does not work Jul 27, 2023
@schittli schittli changed the title PyCharm & python code regions: Is case sensitive / # Region does not work PyCharm & python code regions: # Region does not work Jul 27, 2023
@clutcher
Copy link
Owner

clutcher commented Jul 27, 2023

@schittli So if you will add in Better Highlights region tokens in lowercase, then you can achieve desired functionality?

As for proposals:

  • Always recognizing as case insentive - can't do that, as there are people, who wants it case sensitive.
  • Case senstivite option and RegExp are great ideas, but I need to firstly rewrite current UI before adding more configurable options. So don't expect this functionality in nearest months.
  • I also have idea to add some "custom code folding" functionality to plugin, maybe by regexp. But it would be also after rewriting of existing UI.

@clutcher clutcher added the enhancement New feature or request label Jul 27, 2023
@schittli
Copy link
Author

Hello @clutcher

So if you will add in Better Highlights region tokens in lowercase, then you can achieve desired functionality?

Yes, if I use source code region tokens in lowercase, then PyCharm recognizes the regions and allows to fold them (but Better Highlights does not highlight the regions)

If I use source code region tokens in uppercase, then PyCharm does not recognizes the regions (but Better Highlights highlights them)

I had not seen that we can define the Better Highlights tokens in the settings.
Therefore, this bug report was created with this configuration:

image

So I just tested it now and changed the tokens to region and end
but Better Highlights was still not able to detect the regions in the Python source code (this might not work because I work in freemium mode, I've got a warning)

ℹ️ If you want to solve the case-sensitive problem in general, ...

then custom regex would really help, because users work with different file types (html, css, python, etc.) and with a custom Regex they cold configure an expression which works with all their file types 😃

Thanks a lot, kind regards,
Thomas

@clutcher
Copy link
Owner

@schittli Region works same in free and paid version. I'll take a look why it doesn't work with lower case region and end keyword.

@clutcher clutcher added the bug Something isn't working label Jul 28, 2023
@clutcher clutcher self-assigned this Jul 28, 2023
@clutcher
Copy link
Owner

@schittli Just checked and do not see any issues:

Screenshot_20230728_110859

Screenshot_20230728_110745

Screenshot_20230728_110803

@clutcher
Copy link
Owner

clutcher commented Aug 2, 2023

@schittli Can you recheck and confirm if you can use that approach untill I'll put more robust settings?

@clutcher clutcher added the question Further information is requested label Aug 9, 2023
@clutcher clutcher removed their assignment Dec 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants