diff --git a/Userland/Applications/HexEditor/HexEditor.cpp b/Userland/Applications/HexEditor/HexEditor.cpp index 62d292c485..409535ab9b 100644 --- a/Userland/Applications/HexEditor/HexEditor.cpp +++ b/Userland/Applications/HexEditor/HexEditor.cpp @@ -185,12 +185,12 @@ bool HexEditor::copy_selected_hex_to_clipboard_as_c_code() output_string_builder.append(" "); for (size_t i = m_selection_start, j = 1; i < m_selection_end; i++, j++) { output_string_builder.appendff("{:#02X}", m_document->get(i).value); - if (i != m_selection_end) + if (i >= m_selection_end - 1) + continue; + if ((j % 12) == 0) + output_string_builder.append(",\n "); + else output_string_builder.append(", "); - if ((j % 12) == 0) { - output_string_builder.append("\n"); - output_string_builder.append(" "); - } } output_string_builder.append("\n};\n");