nmsmith22389 / vscode-incrementor

Advanced increment / decrement actions for (almost) anything.
13 stars 11 forks source link

More freedom for incrementor.enums.values regex #43

Open uberkael opened 1 month ago

uberkael commented 1 month ago

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 commented 1 month ago

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 commented 1 month ago

~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 commented 1 month ago

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

Thanks.

uberkael commented 1 month ago

I have created a Pull Request with the code and included a video. https://github.com/nmsmith22389/vscode-incrementor/pull/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.

https://github.com/user-attachments/assets/309ba39e-2177-42af-adb2-8c7b4db345df

nmsmith22389 commented 1 month ago

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!