diff --git a/AK/StringView.cpp b/AK/StringView.cpp index e9e8c7f90f..83892bc50b 100644 --- a/AK/StringView.cpp +++ b/AK/StringView.cpp @@ -68,12 +68,12 @@ Vector StringView::split_view(StringView separator, SplitBehavior sp return parts; } -Vector StringView::lines(bool consider_cr) const +Vector StringView::lines(ConsiderCarriageReturn consider_carriage_return) const { if (is_empty()) return {}; - if (!consider_cr) + if (consider_carriage_return == ConsiderCarriageReturn::No) return split_view('\n', SplitBehavior::KeepEmpty); Vector v; diff --git a/AK/StringView.h b/AK/StringView.h index de2a455500..4a28fab8cb 100644 --- a/AK/StringView.h +++ b/AK/StringView.h @@ -235,7 +235,11 @@ public: // 0.29, the spec defines a line ending as "a newline (U+000A), a carriage // return (U+000D) not followed by a newline, or a carriage return and a // following newline.". - [[nodiscard]] Vector lines(bool consider_cr = true) const; + enum class ConsiderCarriageReturn { + No, + Yes, + }; + [[nodiscard]] Vector lines(ConsiderCarriageReturn = ConsiderCarriageReturn::Yes) const; // Create a new substring view of this string view, starting either at the beginning of // the given substring view, or after its end, and continuing until the end of this string diff --git a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp index dd3855d27b..e447b40db5 100644 --- a/Userland/Applications/Spreadsheet/SpreadsheetView.cpp +++ b/Userland/Applications/Spreadsheet/SpreadsheetView.cpp @@ -425,7 +425,7 @@ SpreadsheetView::SpreadsheetView(Sheet& sheet) StringView urls { data.data(), data.size() }; Vector source_positions, target_positions; - for (auto& line : urls.lines(false)) { + for (auto& line : urls.lines(StringView::ConsiderCarriageReturn::No)) { auto position = m_sheet->position_from_url(line); if (position.has_value()) source_positions.append(position.release_value()); diff --git a/Userland/Libraries/LibRegex/RegexMatch.h b/Userland/Libraries/LibRegex/RegexMatch.h index 3a13280b21..296eb421ff 100644 --- a/Userland/Libraries/LibRegex/RegexMatch.h +++ b/Userland/Libraries/LibRegex/RegexMatch.h @@ -303,7 +303,7 @@ public: { return m_view.visit( [](StringView view) { - auto views = view.lines(false); + auto views = view.lines(StringView::ConsiderCarriageReturn::No); Vector new_views; for (auto& view : views) new_views.empend(view);