CppEditor: Fix renaming location for "optimize for loop" quickfix

Use the start of the variable name, not the end. It's more natural, and
it prevents problems with the clang code model, as isCursorOnIdentifier()
returns false if the cursor is after the last character of the name.

Change-Id: I368ccf5cef9c3fb04c0902e49f8a189c102c481f
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2021-01-14 16:18:00 +01:00
parent 663a12e00f
commit 887cb05b98

View File

@@ -7245,7 +7245,7 @@ public:
}
}
renamePos = file->endOf(m_forAst->initializer) + 1 + varName.length();
renamePos = file->endOf(m_forAst->initializer) + 1;
change.insert(file->endOf(m_forAst->initializer) - 1, // "-1" because of ";"
QLatin1String(", ") + varName + QLatin1String(" = ")
+ file->textOf(m_expression));