Skip to content

Conversation

@PramodGarg
Copy link

Added a new action that allows to cycle all the possible conversions.

@silvasur
Copy link
Owner

silvasur commented Oct 1, 2022

First, sorry for the late reply 🙇‍♀️

I'm not convinced this cycling through the conversions makes it easier to access the conversions. This is mostly what the CamelCase Plugin is doing. I developed my plugin precisely because I didn't like this cycling through all the case converstions. I think it's a lot easier to have separate actions for each casing. This lets you immediately do what you need in a particular situation and makes it possible to use the conversions in a macro. For discoverability, there is the "Edit > Convert Case" menu, also all actions are named "Convert Case: ..." to make them easily searchable in the "Find Action" palette.


Some remarks on the code:

If you have multiple selections and invoke the new cycle action, each selection will have another casing. This happens because replace gets called for each selection instead of once per replacement.

0001-0319.webm

As a user I would have expected that all selections get the same casing. This is also how all other conversion actions in this plugin work. So this should be fixed.

I don't really like that all actions needed changing. They are now all calling replaceString from replace. If instead of

case CAMEL:
                return CamelCaseAction.replaceString(s);

you'd do this

case CAMEL:
                return (new CamelCaseAction()).replace(s);

no changes to the other actions would then be necessary.

Also with that change, you could just store the SelectionReplacerAction objects in a static list and use the counter to index into it directly, which would remove the need for the ConversionType enum.

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.

2 participants