diff options
author | Maciej Zygmanowski <sppmacd@pm.me> | 2021-04-05 15:34:39 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-04-05 17:06:07 +0200 |
commit | 8646f8f4ad3cc7a2bdd6278e6dc3422f5a667814 (patch) | |
tree | 340c3c4ee27af9f8dda76a56d87df4aeaf432af3 /Userland | |
parent | 1f65c2a981aa91839944d6c5929fb310be5a64d0 (diff) | |
download | serenity-8646f8f4ad3cc7a2bdd6278e6dc3422f5a667814.zip |
LibGUI: Use normalized TextRange for early empty string check
Fixes #6141. Allows to copy "backward" selections.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Libraries/LibGUI/TextDocument.cpp | 4 |
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) { |