From 8646f8f4ad3cc7a2bdd6278e6dc3422f5a667814 Mon Sep 17 00:00:00 2001 From: Maciej Zygmanowski Date: Mon, 5 Apr 2021 15:34:39 +0200 Subject: LibGUI: Use normalized TextRange for early empty string check Fixes #6141. Allows to copy "backward" selections. --- Userland/Libraries/LibGUI/TextDocument.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Userland/Libraries/LibGUI/TextDocument.cpp b/Userland/Libraries/LibGUI/TextDocument.cpp index 170d72d665..d7753c5808 100644 --- a/Userland/Libraries/LibGUI/TextDocument.cpp +++ b/Userland/Libraries/LibGUI/TextDocument.cpp @@ -343,9 +343,9 @@ String TextDocument::text() const String TextDocument::text_in_range(const TextRange& a_range) const { - if (is_empty() || line_count() < a_range.end().line() - a_range.start().line() || line(a_range.start().line()).is_empty()) - return String(""); auto range = a_range.normalized(); + if (is_empty() || line_count() < range.end().line() - range.start().line() || line(range.start().line()).is_empty()) + return String(""); StringBuilder builder; for (size_t i = range.start().line(); i <= range.end().line(); ++i) { -- cgit v1.2.3