https://bugs.kde.org/show_bug.cgi?id=365437

--- Comment #8 from Piotr Mierzwinski <piotr.mierzwin...@gmail.com> ---
(In reply to Igor Kushnir from comment #6)
> I have experienced similar Rename bugs in KDevelop 5.5.0:
>     1) it always inserted spaces between the renamed variable and
> parentheses;
>     2) sometimes it inserted out-of-place braces.
> 
> After some debugging I determined that Source Formatter kicks in during the
> Rename variable refactoring in DocumentChangeSetPrivate::generateNewText():
> 
>     if (formatter && (formatPolicy == DocumentChangeSet::AutoFormatChanges
>                               || formatPolicy ==
> DocumentChangeSet::AutoFormatChangesKeepIndentation)) {
> ... }
> 
> 
> GrepOutputModel sets formatPolicy to DocumentChangeSet::NoAutoFormat, so
> Find/Replace in Files does not cause such bugs. Neither does simple
> KTextEditor's Replace within a file.
> 
> It turned out that my Source Formatter for the C++ Language was set to the
> default Artistic Style->1TBS. After switching to Artistic Style->Qt, at
> least the easily reproducible space insertion issue is gone. Not sure about
> the spurious braces yet.

Could you tell me where you found another code formaters for KDevelop? I have
only these provided in kdevelop package?
And because of this I used only such.

Second thing here.
Applying of Formatter is another issue in KDevelop, which nobody fixed since
several years. There couple bugs which I reported about this. Check following:
#358798, #358801, also 4 years ago. Shortly. Applying Formatter doesn't effect,
at least in configuration window. Whatever I  select in configuration, when I
back then always is the same, so: "C" and "Gnu Indent: Kernighan & Ritchie".


> Piotr, have you tried reproducing this bug and Bug 317299 with different C++
> Source Formatters configured in KDevelop settings?

To be honest, I don't remember if I changed Formatter and made tests more that
one test couple or only I experiences issue with one.
I started test with my "second example", reported at 2016-07-11 23:55:16 CEST.
I selected Formatter: "C++", "Gnu Indent: Kernighan & Ritchie".
After using "Rename" option with parameter name I didn't get broken code by
curly brackets. After this I user "Update declaration" and here I got unwanted
space. 

In definition of used Formatter I can see declaration of method looking like
this:
"void bar(int foo) {"

My original code looked like this:
"void bar( QAction *pAction );"

after I used "Update declaration" I got:
"void bar (QAction * pAction2);"

As you can see there is unwanted space.
I made another test renaming pAction2 with pAction2 in the same method.
In result. Code has not been broken by curly brackets and after I use "Update
declaration" I got:
"void bar(QAction * pAction2);"

As you can see there is unwanted space disappeared.
My conclusion is that Formatter doesn't work correctly
Second thing is that, when I opened configuration I found "C", "Gnu Indent:
Kernighan & Ritchie".

I tried reproduce issue (with broken code by curly brackets) with first example
and also nothing wrong happened.

To be honest just coding since several months I just avoid this function to
don't have broken code.
I will test more "Update declaration" and "Rename", maybe part of the fault
lies with Source Formater as you said.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to