Repository: godotengine/godot
File: scene/gui/rich_text_label.cpp (C++)

Code before:
						l.text_buf_disp->resize_object(it->rid, Size2(table->total_width, table->total_height), table->inline_align, Math::round(table->rows_baseline[row_idx]));
					}
				} else {
					l.text_buf->resize_object(it->rid, Size2(table->total_width, table->total_height), table->inline_align);
					if (l.text_buf_disp.is_valid() && l.text_buf_disp->has_object(it->rid)) {
						l.text_buf_disp->resize_object(it->rid, Size2(table->total_width, table->total_height), table->inline_align);
					}
				}
			} break;
			default:
				break;
		}
	}

	l.offset.y = p_h;
	return _calculate_line_vertical_offset(l);
}

int RichTextLabel::_get_line_max_width(ItemFrame *p_frame, int p_line) const {
	ERR_FAIL_NULL_V(p_frame, 0);
	ERR_FAIL_INDEX_V(p_line, (int)p_frame->lines.size(), 0);

	Line &l = p_frame->lines[p_line];
	MutexLock lock(l.text_buf->get_mutex());

	int max_width = std::ceil(l.text_buf->get_non_wrapped_size().x);

	Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr;
	for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) {
		if (it->type != ITEM_TABLE) {
			continue;
		}

		ItemTable *table = static_cast<ItemTable *>(it);

		// Subtract the table's width recorded in text_buf.
		max_width -= table->total_width;

		// Recalculate the maximum width of the table.
		const int col_count = table->columns.size();
		max_width += theme_cache.table_h_separation * col_count;

		if (table->column_max_width_dirty) {
			int idx = 0;
			for (Item *E : table->subitems) {
				ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames.
				ItemFrame *frame = static_cast<ItemFrame *>(E);
				int column = idx % col_count;
				ItemTable::Column &C = table->columns[column];
				for (int i = 0; i < (int)frame->lines.size(); i++) {
					C.max_width = MAX(C.max_width, _get_line_max_width(frame, i));

Review comment (suggestion):
```suggestion
	int max_width = Math::ceil(l.text_buf->get_non_wrapped_size().x);
```

Code after:
						l.text_buf_disp->resize_object(it->rid, Size2(table->total_width, table->total_height), table->inline_align, Math::round(table->rows_baseline[row_idx]));
					}
				} else {
					l.text_buf->resize_object(it->rid, Size2(table->total_width, table->total_height), table->inline_align);
					if (l.text_buf_disp.is_valid() && l.text_buf_disp->has_object(it->rid)) {
						l.text_buf_disp->resize_object(it->rid, Size2(table->total_width, table->total_height), table->inline_align);
					}
				}
			} break;
			default:
				break;
		}
	}

	l.offset.y = p_h;
	return _calculate_line_vertical_offset(l);
}

int RichTextLabel::_get_line_max_width(ItemFrame *p_frame, int p_line) const {
	ERR_FAIL_NULL_V(p_frame, 0);
	ERR_FAIL_INDEX_V(p_line, (int)p_frame->lines.size(), 0);

	Line &l = p_frame->lines[p_line];
	MutexLock lock(l.text_buf->get_mutex());

	int max_width = Math::ceil(l.text_buf->get_non_wrapped_size().x);

	Item *it_to = (p_line + 1 < (int)p_frame->lines.size()) ? p_frame->lines[p_line + 1].from : nullptr;
	for (Item *it = l.from; it && it != it_to; it = _get_next_item(it)) {
		if (it->type != ITEM_TABLE) {
			continue;
		}

		ItemTable *table = static_cast<ItemTable *>(it);

		// Subtract the table's width recorded in text_buf.
		max_width -= table->total_width;

		// Recalculate the maximum width of the table.
		const int col_count = table->columns.size();
		max_width += theme_cache.table_h_separation * col_count;

		if (table->column_max_width_dirty) {
			int idx = 0;
			for (Item *E : table->subitems) {
				ERR_CONTINUE(E->type != ITEM_FRAME); // Children should all be frames.
				ItemFrame *frame = static_cast<ItemFrame *>(E);
				int column = idx % col_count;
				ItemTable::Column &C = table->columns[column];
				for (int i = 0; i < (int)frame->lines.size(); i++) {
					C.max_width = MAX(C.max_width, _get_line_max_width(frame, i));