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

            Bug ID: 415913
           Summary: KDevelop code formatter generates incorrect formatting
                    with kdev_format_source
           Product: kdevelop
           Version: 5.4.5
          Platform: Archlinux Packages
                OS: Linux
            Status: REPORTED
          Severity: normal
          Priority: NOR
         Component: Astyle
          Assignee: kdevelop-bugs-n...@kde.org
          Reporter: scott.dea...@gmail.com
  Target Milestone: ---

SUMMARY

Code formatting not working correctly when using source formatter "KDevelop:
kdev_format_source" with uncrustify.

STEPS TO REPRODUCE

1. Generate uncrustify config file: uncrustify --update-config > myconfig.cfg
2. Open KDevelop
3. Navigate to Settings > Configure KDevelop > Source Formatter.
4. For the "Language" dropdown, select "C++".
5. For the "Formatter" dropdown, select "Custom Script Formatter".
6. In the "Style" listbox, select "KDevelop: kdev_format_source".
7. Click on the "OK" button.
8. Create "format_source" file in the project's root directory.
9. In the "format_source" file, add: */*.cpp: uncrustify -c myconfig.cfg
--no-backup $TMPFILE
10. In KDevelop, open a .cpp file that includes a function like:


void test(int someParam1, int someParam2){
  std::cout<<"This is a test..."<<std::endl;
}

11. Right-click in the editor, and select "Reformat Source".

OBSERVED RESULT

  void test(int someParam1, int someParam2)
    {
    std::cout<<"This is a test..."<<std::endl;
  }


EXPECTED RESULT

void test(int someParam1, int someParam2)
{
  std::cout<<"This is a test..."<<std::endl;
}

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 5.17.4
KDE Frameworks Version: 5.65.0
Qt Version: 5.14.0

ADDITIONAL INFORMATION

uncrustify works as expected if the same command in "format_source" is executed
directly from a terminal:

uncrustify -c myconfig.cfg --no-backup test.cpp

A workaround:

1. Create an external script.
2. For the "command", use: uncrustify -c myconfig.cfg -f %f
3. For "Output", select "Replace contents of current file"
4. Untick the "Show Output" checkbox.
5. Set a keyboard shortcut for the external script.

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

Reply via email to