diff options
author | David Schulz <david.schulz@qt.io> | 2023-05-11 09:34:53 +0200 |
---|---|---|
committer | David Schulz <david.schulz@qt.io> | 2023-05-12 11:03:33 +0000 |
commit | 1a98dda5c417e892cadbedb656829cf2ba4d1d0a (patch) | |
tree | 8b6bb6b91796e16f0a95ec7ec1003d4f49d68523 /src/libs/utils/textutils.h | |
parent | 70609cdec6fa3115af215f16fc5ae48602736027 (diff) |
Utils: fix Text::Range length and remove mid
Those functions are based on the assumption that the passed text starts
at the begin position, which was good enough for search results, but if
used in other parts of the codebase it might give unwanted results.
Calculate the length of the range now as expected and subtract the
beginning lines.
In order to still got the correct results for the text result texts
modify the result range to always start at the first line before
calculating the length of the range.
Also add tests for the modified functionality
Change-Id: I7ccd75b642dda6dd4f738877cbe3543d46c03652
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
Diffstat (limited to 'src/libs/utils/textutils.h')
-rw-r--r-- | src/libs/utils/textutils.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libs/utils/textutils.h b/src/libs/utils/textutils.h index 4ba3b0e1a8..6ee82274dc 100644 --- a/src/libs/utils/textutils.h +++ b/src/libs/utils/textutils.h @@ -37,7 +37,6 @@ public: class QTCREATOR_UTILS_EXPORT Range { public: - QString mid(const QString &text) const { return text.mid(begin.column, length(text)); } int length(const QString &text) const; Position begin; @@ -97,3 +96,4 @@ QTCREATOR_UTILS_EXPORT QString utf16LineTextInUtf8Buffer(const QByteArray &utf8B } // Utils Q_DECLARE_METATYPE(Utils::Text::Position) +Q_DECLARE_METATYPE(Utils::Text::Range) |