layer-renamer icon indicating copy to clipboard operation
layer-renamer copied to clipboard

Reverse naming not working (%-N)

Open Maikenvv opened this issue 6 years ago • 2 comments

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

Maikenvv avatar Apr 24 '18 11:04 Maikenvv

i have the same issue

choomaque avatar Apr 11 '19 16:04 choomaque

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 :)

leonardpauli avatar Apr 16 '19 22:04 leonardpauli