┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews
diff options
context:
space:
mode:
authorShitong Xu <[email protected]>2025-03-23 15:02:24 +0000
committerFelix Ernst <[email protected]>2025-03-23 15:02:24 +0000
commit1e5bc5b3d6ba344da09369802d822f6cd6da7c4c (patch)
tree1f0aa4af5d7afece626fd9707136a0dc380ba5c7 /src/kitemviews
parentc6e77b4a9d75842f68a1ac1e1a1f4f7acf5308e1 (diff)
KFileItemListWidget: wrong selection when renamed file ends with a dot
When a file name ends with a dot, it should be treated like there is no extension. When triggering a rename, the file name except the extension should be selected, which is equal to the full file name when the file ends with a dot.
Diffstat (limited to 'src/kitemviews')
-rw-r--r--src/kitemviews/kfileitemlistwidget.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/kitemviews/kfileitemlistwidget.cpp b/src/kitemviews/kfileitemlistwidget.cpp
index 3a7b37895..e1da7192a 100644
--- a/src/kitemviews/kfileitemlistwidget.cpp
+++ b/src/kitemviews/kfileitemlistwidget.cpp
@@ -176,15 +176,14 @@ int KFileItemListWidget::selectionLength(const QString &text) const
const QString extension = db.suffixForFileName(text);
if (extension.isEmpty()) {
// For an unknown extension just exclude the extension after
- // the last point. This does not work for multiple extensions like
+ // the last dot. This does not work for multiple extensions like
// *.tar.gz but usually this is anyhow a known extension.
indexOfExtension = text.lastIndexOf(QLatin1Char('.'));
- // If no point could be found, use whole text length for selection.
- if (indexOfExtension < 1) {
+ // if there either is no dot, or the last dot is the first or last char, treat as no extension.
+ if (indexOfExtension < 1 || indexOfExtension == text.length() - 1) {
indexOfExtension = text.length();
}
-
} else {
indexOfExtension -= extension.length() + 1;
}