If a file with an unknown extension gets renamed, it is assumed
that the letters after the last point represent the extension and
won't be selected.
BUG: 301893
FIXED-IN: 4.9.0
m_roleEditor->document()->setDefaultTextOption(textOption);
// Select the text without MIME-type extension
m_roleEditor->document()->setDefaultTextOption(textOption);
// Select the text without MIME-type extension
+ // TODO: This is file-item-specific and should be moved
+ // into KFileItemListWidget.
int selectionLength = text.length();
const QString extension = KMimeType::extractKnownExtension(text);
int selectionLength = text.length();
const QString extension = KMimeType::extractKnownExtension(text);
- if (!extension.isEmpty()) {
+ if (extension.isEmpty()) {
+ // For an unknown extension just exclude the extension after
+ // the last point. This does not work for multiple extensions like
+ // *.tar.gz but usually this is anyhow a known extension.
+ selectionLength = text.lastIndexOf(QLatin1Char('.'));
+ } else {
selectionLength -= extension.length() + 1;
}
selectionLength -= extension.length() + 1;
}