You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-07 12:30:27 +00:00
Merge pull request #73196 from Vilcrow/fix-lookup-symbol
Fix jumping to function definition using `Ctrl+LMB` or the "Lookup Symbol" button
This commit is contained in:
@@ -2258,9 +2258,8 @@ bool CodeEdit::is_symbol_lookup_on_click_enabled() const {
|
||||
return symbol_lookup_on_click_enabled;
|
||||
}
|
||||
|
||||
String CodeEdit::get_text_for_symbol_lookup() {
|
||||
String CodeEdit::get_text_for_symbol_lookup() const {
|
||||
Point2i mp = get_local_mouse_pos();
|
||||
|
||||
Point2i pos = get_line_column_at_pos(mp, false);
|
||||
int line = pos.y;
|
||||
int col = pos.x;
|
||||
@@ -2269,25 +2268,29 @@ String CodeEdit::get_text_for_symbol_lookup() {
|
||||
return String();
|
||||
}
|
||||
|
||||
StringBuilder lookup_text;
|
||||
return get_text_with_cursor_char(line, col);
|
||||
}
|
||||
|
||||
String CodeEdit::get_text_with_cursor_char(int p_line, int p_column) const {
|
||||
const int text_size = get_line_count();
|
||||
StringBuilder result;
|
||||
for (int i = 0; i < text_size; i++) {
|
||||
String line_text = get_line(i);
|
||||
|
||||
if (i == line) {
|
||||
lookup_text += line_text.substr(0, col);
|
||||
if (i == p_line && p_column >= 0 && p_column <= line_text.size()) {
|
||||
result += line_text.substr(0, p_column);
|
||||
/* Not unicode, represents the cursor. */
|
||||
lookup_text += String::chr(0xFFFF);
|
||||
lookup_text += line_text.substr(col, line_text.size());
|
||||
result += String::chr(0xFFFF);
|
||||
result += line_text.substr(p_column, line_text.size());
|
||||
} else {
|
||||
lookup_text += line_text;
|
||||
result += line_text;
|
||||
}
|
||||
|
||||
if (i != text_size - 1) {
|
||||
lookup_text += "\n";
|
||||
result += "\n";
|
||||
}
|
||||
}
|
||||
return lookup_text.as_string();
|
||||
|
||||
return result.as_string();
|
||||
}
|
||||
|
||||
void CodeEdit::set_symbol_lookup_word_as_valid(bool p_valid) {
|
||||
@@ -2472,6 +2475,7 @@ void CodeEdit::_bind_methods() {
|
||||
ClassDB::bind_method(D_METHOD("is_symbol_lookup_on_click_enabled"), &CodeEdit::is_symbol_lookup_on_click_enabled);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("get_text_for_symbol_lookup"), &CodeEdit::get_text_for_symbol_lookup);
|
||||
ClassDB::bind_method(D_METHOD("get_text_with_cursor_char", "line", "column"), &CodeEdit::get_text_with_cursor_char);
|
||||
|
||||
ClassDB::bind_method(D_METHOD("set_symbol_lookup_word_as_valid", "valid"), &CodeEdit::set_symbol_lookup_word_as_valid);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user