mirror of
https://github.com/godotengine/godot.git
synced 2025-10-26 19:24:18 +00:00
Improve GDScript indentation error message
This commit is contained in:
parent
0767a1c3f5
commit
626ca50676
3 changed files with 10 additions and 2 deletions
|
|
@ -1064,7 +1064,8 @@ void GDScriptTokenizer::check_indent() {
|
|||
// First time indenting, choose character now.
|
||||
indent_char = current_indent_char;
|
||||
} else if (current_indent_char != indent_char) {
|
||||
Token error = make_error(vformat("Used \"%s\" for indentation instead \"%s\" as used before in the file.", String(¤t_indent_char, 1).c_escape(), String(&indent_char, 1).c_escape()));
|
||||
Token error = make_error(vformat("Used %s character for indentation instead of %s as used before in the file.",
|
||||
_get_indent_char_name(current_indent_char), _get_indent_char_name(indent_char)));
|
||||
error.start_line = line;
|
||||
error.start_column = 1;
|
||||
error.leftmost_column = 1;
|
||||
|
|
@ -1114,6 +1115,12 @@ void GDScriptTokenizer::check_indent() {
|
|||
}
|
||||
}
|
||||
|
||||
String GDScriptTokenizer::_get_indent_char_name(char32_t ch) {
|
||||
ERR_FAIL_COND_V(ch != ' ' && ch != '\t', String(&ch, 1).c_escape());
|
||||
|
||||
return ch == ' ' ? "space" : "tab";
|
||||
}
|
||||
|
||||
void GDScriptTokenizer::_skip_whitespace() {
|
||||
if (pending_indents != 0) {
|
||||
// Still have some indent/dedent tokens to give.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue