Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable regex based highlighting for runtime errors #7526

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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) { }