diff --git a/Userland/Libraries/LibDiff/Generator.cpp b/Userland/Libraries/LibDiff/Generator.cpp index 677022b570..c952ea8702 100644 --- a/Userland/Libraries/LibDiff/Generator.cpp +++ b/Userland/Libraries/LibDiff/Generator.cpp @@ -72,9 +72,9 @@ ErrorOr> from_text(StringView old_text, StringView new_text) cur_hunk = { i, j, {}, {} }; } if (direction == Direction::Down) { - TRY(cur_hunk.added_lines.try_append(new_lines[j])); + TRY(cur_hunk.added_lines.try_append(TRY(String::from_utf8(new_lines[j])))); } else if (direction == Direction::Right) { - TRY(cur_hunk.removed_lines.try_append(old_lines[i])); + TRY(cur_hunk.removed_lines.try_append(TRY(String::from_utf8(old_lines[i])))); } return {}; diff --git a/Userland/Libraries/LibDiff/Hunks.cpp b/Userland/Libraries/LibDiff/Hunks.cpp index 4193566e10..cd7e54cb6c 100644 --- a/Userland/Libraries/LibDiff/Hunks.cpp +++ b/Userland/Libraries/LibDiff/Hunks.cpp @@ -41,12 +41,12 @@ ErrorOr> parse_hunks(StringView diff) hunk.target_start_line = current_location.target_start_line; while (line_index < diff_lines.size() && diff_lines[line_index][0] == '-') { - TRY(hunk.removed_lines.try_append(diff_lines[line_index].substring_view(1, diff_lines[line_index].length() - 1))); + TRY(hunk.removed_lines.try_append(TRY(String::from_utf8(diff_lines[line_index].substring_view(1, diff_lines[line_index].length() - 1))))); current_location.apply_offset(1, HunkLocation::LocationType::Original); ++line_index; } while (line_index < diff_lines.size() && diff_lines[line_index][0] == '+') { - TRY(hunk.added_lines.try_append(diff_lines[line_index].substring_view(1, diff_lines[line_index].length() - 1))); + TRY(hunk.added_lines.try_append(TRY(String::from_utf8(diff_lines[line_index].substring_view(1, diff_lines[line_index].length() - 1))))); current_location.apply_offset(1, HunkLocation::LocationType::Target); ++line_index; } diff --git a/Userland/Libraries/LibDiff/Hunks.h b/Userland/Libraries/LibDiff/Hunks.h index f22b012260..03ebd0542a 100644 --- a/Userland/Libraries/LibDiff/Hunks.h +++ b/Userland/Libraries/LibDiff/Hunks.h @@ -6,7 +6,7 @@ #pragma once -#include +#include #include #include @@ -29,8 +29,8 @@ struct HunkLocation { struct Hunk { size_t original_start_line { 0 }; size_t target_start_line { 0 }; - Vector removed_lines; - Vector added_lines; + Vector removed_lines; + Vector added_lines; }; ErrorOr> parse_hunks(StringView diff);