Script Editor: Add option to disable documentation tooltips

This commit is contained in:
Danil Alexeev 2025-02-09 11:02:10 +03:00
parent 36d90c73a8
commit ead16435bf
No known key found for this signature in database
GPG key ID: 5A52F75A8679EC57
5 changed files with 35 additions and 8 deletions

View file

@ -1103,6 +1103,10 @@ void ScriptTextEditor::_validate_symbol(const String &p_symbol) {
}
void ScriptTextEditor::_show_symbol_tooltip(const String &p_symbol, int p_row, int p_column) {
if (!EDITOR_GET("text_editor/behavior/documentation/enable_tooltips").booleanize()) {
return;
}
if (p_symbol.begins_with("res://") || p_symbol.begins_with("uid://")) {
EditorHelpBitTooltip::show_tooltip(code_editor->get_text_editor(), "resource||" + p_symbol);
return;
@ -1203,19 +1207,14 @@ void ScriptTextEditor::_show_symbol_tooltip(const String &p_symbol, int p_row, i
}
}
// NOTE: See also `ScriptEditor::_get_debug_tooltip()` for documentation tooltips disabled.
String debug_value = EditorDebuggerNode::get_singleton()->get_var_value(p_symbol);
if (!debug_value.is_empty()) {
constexpr int DISPLAY_LIMIT = 1024;
if (debug_value.size() > DISPLAY_LIMIT) {
debug_value = debug_value.left(DISPLAY_LIMIT) + "... " + TTR("(truncated)");
}
debug_value = debug_value.replace("[", "[lb]");
if (doc_symbol.is_empty()) {
debug_value = p_symbol + ": " + debug_value;
} else {
debug_value = TTR("Current value: ") + debug_value;
}
debug_value = TTR("Current value: ") + debug_value.replace("[", "[lb]");
}
if (!doc_symbol.is_empty() || !debug_value.is_empty()) {