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

Code before:

		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));
				}
				idx++;
			}
			table->column_max_width_dirty = false;
		}

		for (ItemTable::Column &C : table->columns) {
			max_width += C.max_width;
		}
	}

	if (max_width == 0) {
		max_width = std::ceil(l.text_buf->get_non_wrapped_size().x);
	}

	max_width += std::ceil(p_frame->padding.position.x + p_frame->padding.size.x + l.indent);

	return max_width;
}

float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, float p_h, int *r_char_offset) {
	ERR_FAIL_NULL_V(p_frame, p_h);
	ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), p_h);

	Line &l = p_frame->lines[p_line];

	MutexLock lock(l.text_buf->get_mutex());

	BitField<TextServer::LineBreakFlag> autowrap_flags = TextServer::BREAK_MANDATORY;
	switch (autowrap_mode) {
		case TextServer::AUTOWRAP_WORD_SMART:
			autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_ADAPTIVE | TextServer::BREAK_MANDATORY;
			break;
		case TextServer::AUTOWRAP_WORD:
			autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY;
			break;
		case TextServer::AUTOWRAP_ARBITRARY:
			autowrap_flags = TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_MANDATORY;
			break;
		case TextServer::AUTOWRAP_OFF:
			break;

Review comment (suggestion):
```suggestion
	max_width += Math::ceil(p_frame->padding.position.x + p_frame->padding.size.x + l.indent);
```
While we're here 

Code after:
		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));
				}
				idx++;
			}
			table->column_max_width_dirty = false;
		}

		for (ItemTable::Column &C : table->columns) {
			max_width += C.max_width;
		}
	}

	max_width += Math::ceil(p_frame->padding.position.x + p_frame->padding.size.x + l.indent);

	return max_width;
}

float RichTextLabel::_shape_line(ItemFrame *p_frame, int p_line, const Ref<Font> &p_base_font, int p_base_font_size, int p_width, float p_h, int *r_char_offset) {
	ERR_FAIL_NULL_V(p_frame, p_h);
	ERR_FAIL_COND_V(p_line < 0 || p_line >= (int)p_frame->lines.size(), p_h);

	Line &l = p_frame->lines[p_line];

	MutexLock lock(l.text_buf->get_mutex());

	BitField<TextServer::LineBreakFlag> autowrap_flags = TextServer::BREAK_MANDATORY;
	switch (autowrap_mode) {
		case TextServer::AUTOWRAP_WORD_SMART:
			autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_ADAPTIVE | TextServer::BREAK_MANDATORY;
			break;
		case TextServer::AUTOWRAP_WORD:
			autowrap_flags = TextServer::BREAK_WORD_BOUND | TextServer::BREAK_MANDATORY;
			break;
		case TextServer::AUTOWRAP_ARBITRARY:
			autowrap_flags = TextServer::BREAK_GRAPHEME_BOUND | TextServer::BREAK_MANDATORY;
			break;
		case TextServer::AUTOWRAP_OFF: