From 01302b55325614148ba537a601f8013c4c55c135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9trus=20Pradella?= Date: Tue, 11 Jun 2024 07:51:09 -0300 Subject: [PATCH] Sort manipulators based on underlines present on it, assuming it will be more complex as well --- .../evernifecore/placeholder/replacer/RegexReplacer.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main/java/br/com/finalcraft/evernifecore/placeholder/replacer/RegexReplacer.java b/src/main/java/br/com/finalcraft/evernifecore/placeholder/replacer/RegexReplacer.java index 936d3fe6..319a6621 100644 --- a/src/main/java/br/com/finalcraft/evernifecore/placeholder/replacer/RegexReplacer.java +++ b/src/main/java/br/com/finalcraft/evernifecore/placeholder/replacer/RegexReplacer.java @@ -44,7 +44,11 @@ public RegexReplacer addManipulator(String manipulableString, BiFunction manipulatorParser.getManipulator().getPrefix().length())); + Collections.sort(this.manipulators, Comparator.comparing(manipulatorParser -> { + int prefixSize = manipulatorParser.getManipulator().getPrefix().length(); + long underlines = manipulatorParser.getId().chars().filter(c -> c == '_').count(); //More complex manipulators first + return (prefixSize * 1000) + underlines; + })); Collections.reverse(this.manipulators); return this; }