Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shift-alt-F adds blank lines at the end of file every time it's called #15

Open
davydden opened this issue Mar 14, 2018 · 2 comments
Open

Comments

@davydden
Copy link

davydden commented Mar 14, 2018

I have a custom astylerc file which works flawlessly with [email protected] from the command line.

However, when I use the plugin and provide

"astyle.executable": "<blabla>",
"astyle.astylerc": "<blabla>",
"C_Cpp.formatting" : "Disabled"

I see interesting behaviour that each invocation of formatting adds a new line:

screen shot 2018-03-14 at 17 59 55

p.s. macOS 10.13.3, [email protected], [email protected].

@davydden
Copy link
Author

@welkineins any idea what can be wrong?

@chance86
Copy link

chance86 commented Nov 18, 2019

I have a custom astylerc file which works flawlessly with [email protected] from the command line.

However, when I use the plugin and provide

"astyle.executable": "<blabla>",
"astyle.astylerc": "<blabla>",
"C_Cpp.formatting" : "Disabled"

I see interesting behaviour that each invocation of formatting adds a new line:

screen shot 2018-03-14 at 17 59 55

p.s. macOS 10.13.3, [email protected], [email protected].

I have this problem, too. However, this problem only appears in [email protected]. There does not have this problem in [email protected].

Refer to the differences between the two versions. This is my patch for [email protected] to fix this bug:

diff -urN astyle_2.04_original/src/astyle_main.cpp astyle_2.04_fix/src/astyle_main.cpp
--- astyle_2.04_original/src/astyle_main.cpp    2013-11-02 04:31:48.000000000 +0800
+++ astyle_2.04_fix/src/astyle_main.cpp 2019-11-18 16:02:16.934246960 +0800
@@ -435,10 +435,11 @@
        istream* inStream = &cin;
        stringstream outStream;
        char ch;
-       while (!inStream->eof())
+       inStream->get(ch);
+       while (!inStream->eof() && !inStream->fail())
        {
-               inStream->get(ch);
                outStream.put(ch);
+               inStream->get(ch);
        }
        ASStreamIterator<stringstream> streamIterator(&outStream);
        // Windows pipe or redirection always outputs Windows line-ends.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants