mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-03-27 23:37:05 -05:00
fix: String inspector rows not displaying the correctly decoded value
This commit is contained in:
@@ -362,7 +362,7 @@ namespace hex {
|
||||
|
||||
[[nodiscard]] std::optional<std::string> getEnvironmentVariable(const std::string &env);
|
||||
|
||||
[[nodiscard]] std::string limitStringLength(const std::string &string, size_t maxLength);
|
||||
[[nodiscard]] std::string limitStringLength(const std::string &string, size_t maxLength, bool fromBothEnds = true);
|
||||
|
||||
[[nodiscard]] std::optional<std::fs::path> getInitialFilePath();
|
||||
|
||||
|
||||
@@ -601,13 +601,13 @@ namespace hex {
|
||||
return value;
|
||||
}
|
||||
|
||||
[[nodiscard]] std::string limitStringLength(const std::string &string, size_t maxLength) {
|
||||
[[nodiscard]] std::string limitStringLength(const std::string &string, size_t maxLength, bool fromBothEnds) {
|
||||
// If the string is shorter than the max length, return it as is
|
||||
if (string.size() < maxLength)
|
||||
return string;
|
||||
|
||||
// If the string is longer than the max length, find the last space before the max length
|
||||
auto it = string.begin() + maxLength / 2;
|
||||
auto it = string.begin() + (fromBothEnds ? maxLength / 2 : maxLength);
|
||||
while (it != string.begin() && !std::isspace(*it)) --it;
|
||||
|
||||
// If there's no space before the max length, just cut the string
|
||||
@@ -624,6 +624,9 @@ namespace hex {
|
||||
|
||||
auto result = std::string(string.begin(), it) + "…";
|
||||
|
||||
if (!fromBothEnds)
|
||||
return result;
|
||||
|
||||
// If the string is longer than the max length, find the last space before the max length
|
||||
it = string.end() - 1 - maxLength / 2;
|
||||
while (it != string.end() && !std::isspace(*it)) ++it;
|
||||
|
||||
Reference in New Issue
Block a user