summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaciej Zygmanowski <sppmacd@pm.me>2021-04-05 15:34:39 +0200
committerAndreas Kling <kling@serenityos.org>2021-04-05 17:06:07 +0200
commit8646f8f4ad3cc7a2bdd6278e6dc3422f5a667814 (patch)
tree340c3c4ee27af9f8dda76a56d87df4aeaf432af3
parent1f65c2a981aa91839944d6c5929fb310be5a64d0 (diff)
downloadserenity-8646f8f4ad3cc7a2bdd6278e6dc3422f5a667814.zip
LibGUI: Use normalized TextRange for early empty string check
Fixes #6141. Allows to copy "backward" selections.
-rw-r--r--Userland/Libraries/LibGUI/TextDocument.cpp4
1 files 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) {