Commit 0dbaac7b authored by Orgad Shaneh's avatar Orgad Shaneh Committed by Orgad Shaneh
Browse files

TextEditor: Normalize path on Windows



Searching with wrong case causes the code-model to have duplicate files
when opening a file from the results

Change-Id: Id3e4d875230e14c2ab23345a7440372f71f76e8b
Reviewed-by: default avatarFriedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: default avatarDavid Schulz <david.schulz@digia.com>
parent 491ba6fa
......@@ -32,6 +32,7 @@
#include <coreplugin/editormanager/editormanager.h>
#include <find/findplugin.h>
#include <utils/filesearch.h>
#include <utils/fileutils.h>
#include <utils/qtcassert.h>
#include <QDebug>
......@@ -87,14 +88,13 @@ Utils::FileIterator *FindInFiles::files(const QStringList &nameFilters,
QVariant FindInFiles::additionalParameters() const
{
return qVariantFromValue(QDir::fromNativeSeparators(m_directory->currentText()));
return qVariantFromValue(path());
}
QString FindInFiles::label() const
{
const QChar slash = QLatin1Char('/');
const QStringList &nonEmptyComponents = QDir::cleanPath(
QFileInfo(QDir::fromNativeSeparators(m_directory->currentText())).absoluteFilePath())
const QStringList &nonEmptyComponents = QDir::cleanPath(QFileInfo(path()).absoluteFilePath())
.split(slash, QString::SkipEmptyParts);
return tr("Directory '%1':").arg(nonEmptyComponents.isEmpty() ? QString(slash) : nonEmptyComponents.last());
}
......@@ -103,7 +103,7 @@ QString FindInFiles::toolTip() const
{
//: %3 is filled by BaseFileFind::runNewSearch
return tr("Path: %1\nFilter: %2\n%3")
.arg(QDir::toNativeSeparators(QFileInfo(m_directory->currentText()).absoluteFilePath()))
.arg(QDir::toNativeSeparators(QFileInfo(path()).absoluteFilePath()))
.arg(fileNameFilters().join(QLatin1String(",")));
}
......@@ -149,7 +149,7 @@ void FindInFiles::openFileBrowser()
{
if (!m_directory)
return;
QString oldDir = m_directory->currentText();
QString oldDir = path();
if (!QDir(oldDir).exists())
oldDir.clear();
QString dir = QFileDialog::getExistingDirectory(m_configWidget,
......@@ -158,6 +158,12 @@ void FindInFiles::openFileBrowser()
m_directory->setEditText(QDir::toNativeSeparators(dir));
}
QString FindInFiles::path() const
{
return QDir::fromNativeSeparators(Utils::FileUtils::normalizePathName(
m_directory->currentText()));
}
void FindInFiles::writeSettings(QSettings *settings)
{
settings->beginGroup(QLatin1String("FindInFiles"));
......
......@@ -71,6 +71,8 @@ private slots:
void openFileBrowser();
private:
QString path() const;
QStringListModel m_directoryStrings;
QString m_directorySetting;
QPointer<QWidget> m_configWidget;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment