CppEditor: Fix trailing whitespace after extracting a function

... from a block of code.
We must not insert an empty line into the newly created function,
because it gets indented in the first indent operation, resulting in
trailing characters after the actual code has been inserted later.

Fixes: QTCREATORBUG-12118
Change-Id: If438d4de379cae90baa846c112866f2777b44fce
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
Christian Kandeler
2020-07-22 16:37:18 +02:00
parent 086a4be734
commit e4100c31fc
2 changed files with 22 additions and 2 deletions

View File

@@ -5627,6 +5627,26 @@ void CppEditorPlugin::test_quickfix_ExtractFunction_data()
"{\n"
" extracted(c);\n"
"}\n");
QTest::newRow("if-block")
<< _("inline void func()\n"
"{\n"
" int dummy = 0;\n"
" @{start}if@{end} (dummy < 10) {\n"
" ++dummy;\n"
" }\n"
"}\n")
<< _("inline void extracted(int dummy)\n"
"{\n"
" if (dummy < 10) {\n"
" ++dummy;\n"
" }\n"
"}\n\n"
"inline void func()\n"
"{\n"
" int dummy = 0;\n"
" extracted(dummy);\n"
"}\n");
}
void CppEditorPlugin::test_quickfix_ExtractFunction()