shift-alt-F adds blank lines at the end of file every time it's called
davydden opened this issue · comments
I have a custom astylerc
file which works flawlessly with astyle@2.04
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:
p.s. macOS 10.13.3
, astyle@0.7.1
, VSC@1.12.0
.
@welkineins any idea what can be wrong?
I have a custom
astylerc
file which works flawlessly withastyle@2.04
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:
p.s. macOS
10.13.3
,astyle@0.7.1
,VSC@1.12.0
.
I have this problem, too. However, this problem only appears in astyle@2.04
. There does not have this problem in astyle@3.1
.
Refer to the differences between the two versions. This is my patch for astyle@2.04
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.