Bug 121106 - [PATCH] reformat source option "Pad Parentheses" ignored
Summary: [PATCH] reformat source option "Pad Parentheses" ignored
Status: RESOLVED FIXED
Alias: None
Product: kdevelop
Classification: Applications
Component: Astyle (show other bugs)
Version: 3.3.0
Platform: openSUSE Linux
: NOR normal
Target Milestone: ---
Assignee: kdevelop-bugs-null
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-31 19:38 UTC by Luser
Modified: 2006-06-30 17:23 UTC (History)
0 users

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Luser 2006-01-31 19:38:54 UTC
Version:           3.3 (using KDE 3.5.0 Level "a" , SUSE 10.0 UNSUPPORTED)
Compiler:          Target: i586-suse-linux
OS:                Linux (i686) release 2.6.13-15.7-smp

It seems astyle adaptor is using "PadOperators" option for padding both operators and parenthesis:

http://websvn.kde.org/*checkout*/trunk/KDE/kdevelop/parts/astyle/astyle_widget.cpp?content-type=text%2Fplain&rev=443141
  // padding
  config->writeEntry("PadParentheses", Pad_Parentheses->isChecked());
  config->writeEntry("PadOperators", Pad_Operators->isChecked());

http://websvn.kde.org/*checkout*/trunk/KDE/kdevelop/parts/astyle/astyle_adaptor.cpp?content-type=text%2Fplain&rev=443141
  // padding
  setOperatorPaddingMode(config->readBoolEntry("PadOperators", false));
  setParenthesisPaddingMode(config->readBoolEntry("PadOperators", false));
Comment 1 Amilcar do Carmo Lucas 2006-01-31 19:51:04 UTC
Can someone commit it ?
Comment 2 Luser 2006-01-31 20:23:50 UTC
The fix is obvious but just in case :)

- setParenthesisPaddingMode(config->readBoolEntry("PadOperators", false));
+ setParenthesisPaddingMode(config->readBoolEntry("PadParentheses", false));

Comment 3 geiseri 2006-06-30 17:23:33 UTC
SVN commit 556535 by geiseri:

Fixed astyle adaptor is using "PadOperators" option for padding both 
operators and parenthesis.
Bug# 121106

Fixed keep one-line blocks option does nothing.
Bug# 105396

Fixed custom style preview.  This was closed, but it was not working 
right, the preview would always be wrong.
Bug# 70818

BUG: 121106
BUG: 105396
BUG: 78020



 M  +3 -3      astyle_adaptor.cpp  
 M  +18 -1     astyle_widget.cpp  


--- tags/kdevelop/3.3.91/parts/astyle/astyle_adaptor.cpp #556534:556535
@@ -90,11 +90,11 @@
 
   // padding
   setOperatorPaddingMode(config->readBoolEntry("PadOperators", false));
-  setParenthesisPaddingMode(config->readBoolEntry("PadOperators", false));
+  setParenthesisPaddingMode(config->readBoolEntry("PadParentheses", false));
 
   // oneliner
-  setBreakOneLineBlocksMode(config->readBoolEntry("KeepBlocks", false));
-  setSingleStatementsMode(config->readBoolEntry("KeepStatements", false));
+  setBreakOneLineBlocksMode(!config->readBoolEntry("KeepBlocks", false));
+  setSingleStatementsMode(!config->readBoolEntry("KeepStatements", false));
 }
 
 KDevFormatter::KDevFormatter( AStyleWidget * widget )
--- tags/kdevelop/3.3.91/parts/astyle/astyle_widget.cpp #556534:556535
@@ -138,7 +138,24 @@
 
 void AStyleWidget::styleChanged( int id )
 {
-	QString sample = "namespace foospace { class Bar { public: int foo(); private: int m_foo; }; int Bar::foo() { switch (x) { case 1: break; default: break; } if (isBar) { bar(); return m_foo+1; } else return 0; } }";
+	QString sample = "namespace foospace {\n"
+		"class Bar {\n"
+		"public:\n"
+		"int foo();\n"
+		"private:\n"
+		"int m_foo;\n"
+		"};\n"
+		"int Bar::foo() {\n"
+		"switch (x) {\n"
+		"case 1:\n"
+		"break;\n"
+		"default:\n"
+		"break;\n"
+		"} if (isBar) {\n"
+		"bar();\n"
+		"return m_foo+1;\n"
+		"} else return 0; \n"
+		"}\n }\n";
 
 	ConfigTabs->setTabEnabled(tab_2, id == 0);
 	ConfigTabs->setTabEnabled(tab_3, id == 0);