Improve the shader error console output

This makes the line gutter look more like an actual line gutter,
which makes it less confusing.
This commit is contained in:
Hugo Locurcio 2021-07-17 02:37:01 +02:00
parent 4d3c11e85e
commit 43d7b62cb0
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
4 changed files with 16 additions and 4 deletions

View file

@ -987,7 +987,13 @@ Error ShaderCompilerGLES2::compile(VS::ShaderMode p_mode, const String &p_code,
if (err != OK) {
Vector<String> shader = p_code.split("\n");
for (int i = 0; i < shader.size(); i++) {
print_line(itos(i + 1) + " " + shader[i]);
if (i + 1 == parser.get_error_line()) {
// Mark the error line to be visible without having to look at
// the trace at the end.
print_line(vformat("E%4d-> %s", i + 1, shader[i]));
} else {
print_line(vformat("%5d | %s", i + 1, shader[i]));
}
}
_err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER);

View file

@ -119,7 +119,7 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
Vector<String> lines = String(total_code).split("\n");
for (int j = 0; j < lines.size(); j++) {
print_line(itos(line) + ": " + lines[j]);
print_line(vformat("%4d | %s", line, lines[j]));
line++;
}

View file

@ -1031,7 +1031,13 @@ Error ShaderCompilerGLES3::compile(VS::ShaderMode p_mode, const String &p_code,
if (err != OK) {
Vector<String> shader = p_code.split("\n");
for (int i = 0; i < shader.size(); i++) {
print_line(itos(i + 1) + " " + shader[i]);
if (i + 1 == parser.get_error_line()) {
// Mark the error line to be visible without having to look at
// the trace at the end.
print_line(vformat("E%4d-> %s", i + 1, shader[i]));
} else {
print_line(vformat("%5d | %s", i + 1, shader[i]));
}
}
_err_print_error(nullptr, p_path.utf8().get_data(), parser.get_error_line(), parser.get_error_text().utf8().get_data(), ERR_HANDLER_SHADER);

View file

@ -149,7 +149,7 @@ static void _display_error_with_code(const String &p_error, const Vector<const c
Vector<String> lines = String(total_code).split("\n");
for (int j = 0; j < lines.size(); j++) {
print_line(itos(line) + ": " + lines[j]);
print_line(vformat("%4d | %s", line, lines[j]));
line++;
}