| 270 | } |
| 271 | |
| 272 | void TextEdit::Text::invalidate_cache(int p_line, bool p_text_changed) { |
| 273 | ERR_FAIL_INDEX(p_line, text.size()); |
| 274 | |
| 275 | Line &l = text.write[p_line]; |
| 276 | for (const RID rid : l.accessibility_text_root_element) { |
| 277 | if (rid.is_valid()) { |
| 278 | DisplayServer::get_singleton()->accessibility_free_element(rid); |
| 279 | } |
| 280 | } |
| 281 | l.accessibility_text_root_element.clear(); |
| 282 | |
| 283 | if (font.is_null()) { |
| 284 | return; // Not in tree? |
| 285 | } |
| 286 | |
| 287 | Line &text_line = text.write[p_line]; |
| 288 | if (p_text_changed) { |
| 289 | text_line.data_buf->clear(); |
| 290 | } |
| 291 | |
| 292 | BitField<TextServer::LineBreakFlag> flags = brk_flags; |
| 293 | if (indent_wrapped_lines) { |
| 294 | flags.set_flag(TextServer::BREAK_TRIM_INDENT); |
| 295 | } |
| 296 | |
| 297 | text_line.data_buf->set_width(width); |
| 298 | text_line.data_buf->set_direction((TextServer::Direction)direction); |
| 299 | text_line.data_buf->set_break_flags(flags); |
| 300 | text_line.data_buf->set_preserve_control(draw_control_chars); |
| 301 | text_line.data_buf->set_custom_punctuation(get_enabled_word_separators()); |
| 302 | text_line.indent_ofs = -1.0; |
| 303 | |
| 304 | const String &text_with_ime = (!text_line.ime_data.is_empty()) ? text_line.ime_data : text_line.data; |
| 305 | const Array &bidi_override_with_ime = (!text_line.ime_data.is_empty()) ? text_line.ime_bidi_override : text_line.bidi_override; |
| 306 | |
| 307 | if (p_text_changed) { |
| 308 | int from = 0; |
| 309 | if (inline_object_parser.is_valid()) { |
| 310 | // Insert inline object. |
| 311 | Variant parsed_result = inline_object_parser.call(text_with_ime); |
| 312 | if (parsed_result.is_array()) { |
| 313 | Array object_infos = parsed_result; |
| 314 | for (Variant val : object_infos) { |
| 315 | if (!is_inline_info_valid(val)) { |
| 316 | continue; |
| 317 | } |
| 318 | Dictionary info = val; |
| 319 | int start = info["column"]; |
| 320 | float width_ratio = info["width_ratio"]; |
| 321 | String left_string = text_with_ime.substr(from, start - from); |
| 322 | text_line.data_buf->add_string(left_string, font, font_size, language); |
| 323 | text_line.data_buf->add_object(info, Vector2(font_height * width_ratio, font_height), INLINE_ALIGNMENT_CENTER, 0); |
| 324 | from = start; |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | String remaining_string = text_with_ime.substr(from); |
| 329 | text_line.data_buf->add_string(remaining_string, font, font_size, language); |
nothing calls this directly
no test coverage detected