leonardpauli / layer-renamer

Find or rename multiple layers at once using RegEx and flags in Sketch
MIT License
51 stars 2 forks source link

Reverse naming not working (%-N) #7

Open Maikenvv opened 6 years ago

Maikenvv commented 6 years ago

Still using this plugin. It's amazing. However, I've run into a bug?

Mac OS High Sierra Sketch 49.3 Layer renamer 1.3

Steps to reproduce bug

  1. Select layers en open LayerRenamer
  2. Enter a string with %-N in it and click replace all.
  3. No names are changed. It does work when I use %N.

Expected result The layers are renamed counting down.

not-renaming

choomaque commented 5 years ago

i have the same issue

leonardpauli commented 5 years ago

Ahh, yes. Regex miss on my end; https://github.com/leonardpauli/layer-renamer/blob/f1ba7edded29a27e1db59a1da733eb18fbdfe6f6/LayerRenamer.sketchplugin/Contents/Sketch/layerRenamer.sketchscript#L359

should be:

- ...([<>\d+np-]+)?(?:\.?(-)?...
+ ...([<>np]|[+-]?\d)*(?:\.?(-)?...

Otherwise, the - will be part of the previous "path" group. A possible workaround in the current version could be %.-N (notice the dot before the dash to force it to be recognized as the flag for reversing the order, instead of being part of the path).

Thanks for the nice bug report! Had just started a project to remake the whole plugin when the report was posted, though seems like it was a too large of a project at the time, hope to revisit during the summer :)