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

More freedom for incrementor.enums.values regex #43

Open
uberkael opened this issue Oct 6, 2024 · 5 comments
Open

More freedom for incrementor.enums.values regex #43

uberkael opened this issue Oct 6, 2024 · 5 comments

Comments

@uberkael
Copy link

uberkael commented Oct 6, 2024

Thanks for this extension.
I want to do something a bit more complex, like toggle between comparators or booleans operators, something like this

"incrementor.enums.values": [
	...
	[ "==", "!=" ],
	[ "&&", "||" ].
	[ ">", "<", ">=", "<=" ],
	[ "+", "-", "*", "/", "%" ],
	[ "++", "--" ],
	[ "!", "~" ],
	[ "&", "|", "^", "<<", ">>" ],
	[ "&&=", "||=", "+=", "-=", "*=", "/=", "%=", "&=", "|=", "^=", "<<=", ">>="],
]

The problem is the regular expression for is too restrictive:

"incrementor.enums.values": {
	"type": "array",
	"items": {
		"type": "array",
		"items": {
			"type": "string",
			"pattern": "^\\w(?:\\-?\\w+)*$"
		}
	},
	...

It is possible to change "^\\w(?:\\-?\\w+)*$" to "^\\S(?:\\-?\\S+)*$" ? Maybe is a breaking change.
I can make a PR if is accepted.

@nmsmith22389
Copy link
Owner

nmsmith22389 commented Oct 6, 2024

Thanks for the feedback! I really want to get this extension back in working order so any help in the form of PRs you can offer would be greatly appreciated.

I'll have to double check the code to see if everything still functions without much regex restriction.

@nmsmith22389
Copy link
Owner

nmsmith22389 commented Oct 6, 2024

Do you think adding some of the more popular ones as features (like togglable options) would be better?

Actually I'm thinking it's probably best to just have a custom list with some defaults set. (Aside from the numbers)

@uberkael
Copy link
Author

uberkael commented Oct 7, 2024

Probably my regex won't work with [ "++", "--" ] or [ "!", "~"] in normal cases like i++ or !check.
I will try make a PR tomorrow.

Thanks.

@uberkael
Copy link
Author

uberkael commented Oct 11, 2024

I have created a Pull Request with the code and included a video. #44
It seems to work with a few minor adjustments.
However, I wasn't able to run tests for all scenarios, as testing in extensions is not my thing.

vokoscreenNG-2024-10-11_02-32-00.mp4

@nmsmith22389
Copy link
Owner

Good work!

From the video it seems to work well but I can also try it out locally to be sure.

I think I might have to do some research to see if there's a better way to select what the extension needs without getting confused in situations like the ones you described.

But either way I'll try out your PR and if it works well locally I can merge it. Thanks again!

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