LSP: Account for unicode identifiers

This commit is contained in:
HolonProduction 2025-04-13 16:18:19 +02:00
parent 215acd52e8
commit e213737d66
2 changed files with 20 additions and 9 deletions

View file

@ -712,9 +712,9 @@ String ExtendGDScriptParser::get_identifier_under_position(const LSP::Position &
LSP::Position pos = p_position;
if (
pos.character >= line.length() // Cursor at end of line.
|| (!is_ascii_identifier_char(line[pos.character]) // Not on valid identifier char.
|| (!is_unicode_identifier_continue(line[pos.character]) // Not on valid identifier char.
&& (pos.character > 0 // Not line start -> there is a prev char.
&& is_ascii_identifier_char(line[pos.character - 1]) // Prev is valid identifier char.
&& is_unicode_identifier_continue(line[pos.character - 1]) // Prev is valid identifier char.
))) {
pos.character--;
}
@ -723,7 +723,7 @@ String ExtendGDScriptParser::get_identifier_under_position(const LSP::Position &
for (int c = pos.character; c >= 0; c--) {
start_pos = c;
char32_t ch = line[c];
bool valid_char = is_ascii_identifier_char(ch);
bool valid_char = is_unicode_identifier_continue(ch);
if (!valid_char) {
break;
}
@ -732,13 +732,17 @@ String ExtendGDScriptParser::get_identifier_under_position(const LSP::Position &
int end_pos = pos.character;
for (int c = pos.character; c < line.length(); c++) {
char32_t ch = line[c];
bool valid_char = is_ascii_identifier_char(ch);
bool valid_char = is_unicode_identifier_continue(ch);
if (!valid_char) {
break;
}
end_pos = c;
}
if (!is_unicode_identifier_start(line[start_pos + 1])) {
return "";
}
if (start_pos < end_pos) {
r_range.start.line = r_range.end.line = pos.line;
r_range.start.character = start_pos + 1;