diff --git a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp index 0be9d8ee24f..f66a5a686e4 100644 --- a/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp +++ b/src/plugins/qmljseditor/qmljscomponentnamedialog.cpp @@ -168,5 +168,8 @@ QString ComponentNameDialog::isValid() const if (!ui->pathEdit->isValid()) return tr("Invalid path"); + if (QDir(ui->pathEdit->path()).exists(compName + u".qml")) + return tr("Component exists already"); + return QString(); } diff --git a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp index 2cb21f4f555..85202d46559 100644 --- a/src/plugins/qmljstools/qmljsrefactoringchanges.cpp +++ b/src/plugins/qmljstools/qmljsrefactoringchanges.cpp @@ -60,11 +60,18 @@ public: ProjectExplorer::actualTabSettings(fileName, textDocument); CreatorCodeFormatter codeFormatter(tabSettings); codeFormatter.updateStateUntil(block); - do { - const int depth = codeFormatter.indentFor(block); - if (depth != -1) + int depth = codeFormatter.indentFor(block); + if (depth != -1) { + if (QStringView(block.text()).trimmed().isEmpty()) { + // we do not want to indent empty lines (as one is indentent when pressing tab + // assuming that the user will start writing something), and get rid of that + // space if one had pressed tab in an empty line just before refactoring. + // If depth == -1 (inside a multiline string for example) leave the spaces. + depth = 0; + } tabSettings.indentLine(block, depth); + } codeFormatter.updateLineStateChange(block); block = block.next(); } while (block.isValid() && block != end);