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

Add Python language support #52

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

anthonyjvoss
Copy link

Provide users the ability to use the extension with Python files.

Closes #35

@anthonyjvoss
Copy link
Author

@chrmarti If this PR is approved and you're ok with it, can you please add the hacktoberfest label?

@xilopaint
Copy link

Hope this PR can be approved soon.

@a18rhodes
Copy link

This PR has been sitting for ~6 months now, any chance of merging it, or is development on this extension stopped?

@twoframesperminute
Copy link

This PR has been sitting for about a year now. Any chance it will be approved? Or is this extension abandoned?

@chrmarti
Copy link
Owner

@anthonyjvoss Sorry for the delay, could you add Python to the package.json's description and activation events? Thanks!

Update the package.json file to include Python in the package description as well as the activationEvents array.
@anthonyjvoss
Copy link
Author

@chrmarti - I have updated the package.json and pushed the updates to this branch. Thank you for the response.

@sfx2k
Copy link

sfx2k commented Oct 27, 2022

A speedy release would be very happy :)

@@ -14,6 +14,7 @@ export function activate(context: vscode.ExtensionContext) {
const regexRegex = /(^|\s|[()={},:?;])(\/((?:\\\/|\[[^\]]*\]|[^/])+)\/([gimuy]*))(\s|[()={},:?;]|$)/g;
const phpRegexRegex = /(^|\s|[()={},:?;])['|"](\/((?:\\\/|\[[^\]]*\]|[^/])+)\/([gimuy]*))['|"](\s|[()={},:?;]|$)/g;
const haxeRegexRegex = /(^|\s|[()={},:?;])(~\/((?:\\\/|\[[^\]]*\]|[^/])+)\/([gimsu]*))(\s|[.()={},:?;]|$)/g;
const pyRegexRegex = /(^|\s|[()={},:?;])['|"](((?:\\\/|\[[^\]]*\]|[^/])+)([gimuy]*))['|"](\s|[()={},:?;]|$)/g;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I realize this shows the code lens above all strings. That seems a bit too much. Is there a way to reduce this to only match actual regular expressions? E.g., by only matching on strings as parameters to re.search and others?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide a little more detail around what you're seeing and potential drawbacks? This should be providing the same match/highlighting as the other languages.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems to match strings that are not used as regular expressions. E.g.:
image

Since strings are very common this would add a 'Test Regex...' link in many places where it doesn't actually makes sense. (Maybe you disabled code lenses and don't see that.)

Copy link

@YoannQDQ YoannQDQ Feb 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
const pyRegexRegex = /(^|\s|[()={},:?;])['|"](((?:\\\/|\[[^\]]*\]|[^/])+)([gimuy]*))['|"](\s|[()={},:?;]|$)/g;
const pyRegexRegex = /(^|\s|[()={},:?;])r['|"](((?:\\\/|\[[^\]]*\]|[^/])+)([gimuy]*))['|"](\s|[()={},:?;]|$)/g;

Would it be acceptable to change the regex to only match "raw" strings (e.g r"\d{4}-\d{2}")? Sure it's not a perfect solution, as we would miss some simple regexes and also have a bunch of false positives, but if a caveat is added in the doc, it could work.

@sfx2k
Copy link

sfx2k commented Dec 5, 2022

@anthonyjvoss can you fix this?

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

Successfully merging this pull request may close these issues.

Add Python syntax support
7 participants