Bug 230472 - bad usability in source formatter settings (.h and .cpp handled differently)
Summary: bad usability in source formatter settings (.h and .cpp handled differently)
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Arch Linux Linux
: VHI critical
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
: 256737 265004 (view as bug list)
Depends on:
Blocks:
 
Reported: 2010-03-12 17:57 UTC by Jakub Schmidtke
Modified: 2011-03-20 17:53 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In: 4.3


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jakub Schmidtke 2010-03-12 17:57:20 UTC
Version:            (using KDE 4.4.1)
OS:                Linux
Installed from:    Archlinux Packages

Sometimes source formatter stops working properly.
When I run 'reformat' it formats the source differently than it is actualyl set to.
I noticed it ignores the 'indent class' at least.
When I go to formatter settings (the correct settings are selected) and click 'Edit', and 'OK' (with no changes), and 'Apply' (which becomes available after "editing" the settings and try to reformat the source again - it works fine.

Also, I think the 'Break blocks' doesn't seem to work properly (all the time) - it breaks 'else' after 'if', even though only the 'break blocks' option is selected, and 'break all blocks' and 'break if-else' are NOT selected.
Comment 1 Andreas Pakulat 2010-03-12 18:07:17 UTC
I need more specific reproduction steps for the first thing. The second sounds like a bug in astyle which you should report to the astyle bugtracker (IIRC its on sourceforge).
Comment 2 Jakub Schmidtke 2011-03-02 19:06:48 UTC
*** Bug 265004 has been marked as a duplicate of this bug. ***
Comment 3 Jakub Schmidtke 2011-03-02 19:17:28 UTC
I have recently created a new bug about this, I forgot about this one - sorry!

OK, so I managed to reproduce the behavior every time with built-in source
formatters. Steps to reproduce:

* Open kdevelop
* Create a new file.
* Enter following: class Abc { public: Abc() {} };
* Save it as /tmp/test.cpp
* Open "Settings->Configure Kdevelop", go to "Source formatter", and select
"Artistic style" and "GNU" style.
* Click OK
* From "Edit" select "Reformat source".
* It reformats the content. It doesn't look exactly as expected but that is
probably a different issue. The important part is that the first '{' is
indented.
* Save the file.
* Close kdevelop
* Open kdevelop
* If not already opened, open /tmp/test.cpp
* Run "Edit->Reformat source"
* The source is reformatted. The indentation before '{' and 'public:' is gone
now.
* Open "Settings->Configure Kdevelop"
* Go to "Source Formatter"
* Click "OK" (without changing anything - the GNU style is still selected)
* Run "Edit->Reformat source"
* The file is reformatted again, using the GNU style
* After closing again and re-opening kdevelop, reformatter, again, doesn't
respect the selected style.

"GNU" style is just an example, that is built-in and demonstrates the problem.
Using custom formatter instead causes the same problem.
Comment 4 Jakub Schmidtke 2011-03-02 19:24:28 UTC
The procedure above was done in KDE 4.6.0, with kdevplatform 1.2.0 and kdevelop 4.2.0.
Comment 5 Milian Wolff 2011-03-03 10:22:31 UTC
will fix that today
Comment 6 Milian Wolff 2011-03-03 17:35:16 UTC
the problem here is that .h and .cpp files have different mimetypes and you have to configure both

I've started discussion on this issue on our developer mailing list, lets see how we improve the situation
Comment 7 Jakub Schmidtke 2011-03-03 17:53:01 UTC
So maybe the problem is somewhere else. Indeed, when I configured all the types in 'mimetypes' list in Source formatter's settings the problem went away.

But, if I had it selected for only one (and the wrong one) of the mimetypes, why going to that settings and simply clicking 'OK' affected the behaviour?
If it was simply just the wrong mimetype configured, it should always be the different setting used, right?

Also, since I got you interested, would it be possible for you to look at bug 266710 as well? It is really frustrating when you are used to copying and pasting over existing selection... Thanks!
Comment 8 Dmitry 2011-03-17 22:23:09 UTC
Git commit 5388d06d4135853bc2f904252cf3f691f2363a6f by Dmitry Risenberg.
Committed on 15/03/2011 at 23:01.
Pushed by risenberg into branch 'master'.

Set formatter and style per language, not mime type.
Make style references from different languages with the same name one style object.

BUG: 230472
REVIEW: 100868

M  +29   -8    shell/languagecontroller.cpp     
M  +3    -0    shell/languagecontroller.h     
M  +1    -1    shell/settings/CMakeLists.txt     
M  +181  -132  shell/settings/sourceformattersettings.cpp     
M  +17   -10   shell/settings/sourceformattersettings.h     
M  +1    -1    shell/settings/sourceformattersettings.ui     

http://commits.kde.org/kdevplatform/5388d06d4135853bc2f904252cf3f691f2363a6f
Comment 9 Dmitry 2011-03-20 17:53:18 UTC
*** Bug 256737 has been marked as a duplicate of this bug. ***