Skip to content

Commit

Permalink
Enable regex-based highlighting for runtime errors (#7526)
Browse files Browse the repository at this point in the history
  • Loading branch information
sovdeeth authored Feb 1, 2025
1 parent aa19393 commit c278805
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void printError(@NotNull RuntimeError error) {
ErrorSource source = error.source();
String code = source.lineText();
if (error.toHighlight() != null && !error.toHighlight().isEmpty())
code = code.replace("§", "&").replace(error.toHighlight(), "§f§n" + error.toHighlight() + "§7");
code = code.replace("§", "&").replaceFirst(error.toHighlight(), "§f§n$0§7");

SkriptLogger.sendFormatted(Bukkit.getConsoleSender(),
String.format(skriptInfo, source.script(), source.syntaxName(), source.syntaxType()) +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
* @param source The source of the error
* @param error The message to display as the error
* @param toHighlight Optionally, the text within the emitting line to highlight.
* This should be treated as a regex pattern and will highlight the first match it finds.
*/
public record RuntimeError(Level level, ErrorSource source, String error, @Nullable String toHighlight) { }

0 comments on commit c278805

Please sign in to comment.