From: Peter Penz Date: Sat, 16 Jun 2012 20:51:39 +0000 (+0200) Subject: Renaming: Don't select unknown extensions X-Git-Url: https://cloud.milkyroute.net/gitweb/dolphin.git/commitdiff_plain/53b01d5aff7617f48cfbbfc34f8ff6f0a6a2f052?ds=sidebyside Renaming: Don't select unknown extensions 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 --- diff --git a/src/kitemviews/kstandarditemlistwidget.cpp b/src/kitemviews/kstandarditemlistwidget.cpp index acd426cf2..e584c0678 100644 --- a/src/kitemviews/kstandarditemlistwidget.cpp +++ b/src/kitemviews/kstandarditemlistwidget.cpp @@ -606,10 +606,17 @@ void KStandardItemListWidget::editedRoleChanged(const QByteArray& current, const 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); - 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; }