diff --git a/AStyleLib/ASBeautifier.cpp b/AStyleLib/ASBeautifier.cpp index af4b8c0..176cd7b 100644 --- a/AStyleLib/ASBeautifier.cpp +++ b/AStyleLib/ASBeautifier.cpp @@ -896,7 +896,6 @@ string ASBeautifier::beautify(const string& originalLine) lineOpensWithComment = false; lineStartsInComment = isInComment; previousLineProbationTab = false; - haveLineContinuationChar = false; lineOpeningBlocksNum = 0; lineClosingBlocksNum = 0; if (isImmediatelyPostObjCMethodDefinition) @@ -2464,12 +2463,10 @@ string ASBeautifier::getIndentedSpaceEquivalent(const string& line_) const string convertedLine = spaceIndent + line_; for (size_t i = spaceIndent.length(); i < convertedLine.length(); i++) { - size_t tabCount_ = 0; if (convertedLine[i] == '\t') { - size_t numSpaces = indentLength - ((tabCount_ + i) % indentLength); + size_t numSpaces = indentLength - (i % indentLength); convertedLine.replace(i, 1, numSpaces, ' '); - ++tabCount_; i += indentLength - 1; } } @@ -2490,6 +2487,12 @@ void ASBeautifier::parseCurrentLine(const string& line) bool previousLineProbation = (probationHeader != NULL); char ch = ' '; int tabIncrementIn = 0; + if (isInQuote + && !haveLineContinuationChar + && !isInVerbatimQuote + && !isInAsm) + isInQuote = false; // missing closing quote + haveLineContinuationChar = false; for (size_t i = 0; i < line.length(); i++) { @@ -2570,12 +2573,13 @@ void ASBeautifier::parseCurrentLine(const string& line) } else if (isSharpStyle()) { - if (peekNextChar(line, i) == '"') // check consecutive quotes + if (line.compare(i, 2, "\"\"") == 0) i++; else { isInQuote = false; isInVerbatimQuote = false; + continue; } } } diff --git a/AStyleLib/ASFormatter.cpp b/AStyleLib/ASFormatter.cpp index f78c616..7f6bf23 100644 --- a/AStyleLib/ASFormatter.cpp +++ b/AStyleLib/ASFormatter.cpp @@ -1145,17 +1145,14 @@ string ASFormatter::nextLine() if (newHeader != NULL) { - // recognize closing headers of do..while, if..else, try..catch..finally - if ((newHeader == &AS_ELSE && currentHeader == &AS_IF) - || (newHeader == &AS_WHILE && currentHeader == &AS_DO) - || (newHeader == &AS_CATCH && currentHeader == &AS_TRY) - || (newHeader == &AS_CATCH && currentHeader == &AS_CATCH) - || (newHeader == &AS_FINALLY && currentHeader == &AS_TRY) - || (newHeader == &AS_FINALLY && currentHeader == &AS_CATCH) - || (newHeader == &_AS_FINALLY && currentHeader == &_AS_TRY) - || (newHeader == &_AS_EXCEPT && currentHeader == &_AS_TRY) - || (newHeader == &AS_SET && currentHeader == &AS_GET) - || (newHeader == &AS_REMOVE && currentHeader == &AS_ADD)) + foundClosingHeader = isClosingHeader(newHeader); + + if (!foundClosingHeader + && ((newHeader == &AS_WHILE && currentHeader == &AS_DO) + || (newHeader == &_AS_FINALLY && currentHeader == &_AS_TRY) + || (newHeader == &_AS_EXCEPT && currentHeader == &_AS_TRY) + || (newHeader == &AS_SET && currentHeader == &AS_GET) + || (newHeader == &AS_REMOVE && currentHeader == &AS_ADD))) foundClosingHeader = true; const string* previousHeader = currentHeader; @@ -4596,7 +4593,10 @@ void ASFormatter::formatOpeningBracket(BracketType bracketType) breakLine(); } else if (!isBracketType(bracketType, SINGLE_LINE_TYPE)) + { + formattedLine = rtrim(formattedLine); breakLine(); + } else if ((shouldBreakOneLineBlocks || isBracketType(bracketType, BREAK_BLOCK_TYPE)) && !isBracketType(bracketType, EMPTY_BLOCK_TYPE)) breakLine(); @@ -5502,7 +5502,12 @@ void ASFormatter::formatCommentOpener() && !isImmediatelyPostComment && !isImmediatelyPostLineComment) { - if (bracketFormatMode == NONE_MODE) + if (isBracketType(bracketTypeStack->back(), NAMESPACE_TYPE)) + { + // namespace run-in is always broken. + isInLineBreak = true; + } + else if (bracketFormatMode == NONE_MODE) { // should a run-in statement be attached? if (currentLineBeginsWithBracket) @@ -5776,7 +5781,8 @@ void ASFormatter::formatQuoteBody() } else if (isSharpStyle()) { - if (peekNextChar() == '"') // check consecutive quotes + if ((int) currentLine.length() > charNum + 1 + && currentLine[charNum + 1] == '"') // check consecutive quotes { appendSequence("\"\""); goForward(1); @@ -5805,6 +5811,10 @@ void ASFormatter::formatQuoteBody() appendCurrentChar(); } } + if (charNum + 1 >= (int) currentLine.length() + && currentChar != '\\' + && !isInVerbatimQuote) + isInQuote = false; // missing closing quote } /** diff --git a/AStyleLib/astyle_main.cpp b/AStyleLib/astyle_main.cpp index 07abf3d..b4775b2 100644 --- a/AStyleLib/astyle_main.cpp +++ b/AStyleLib/astyle_main.cpp @@ -96,7 +96,7 @@ namespace astyle { jmethodID g_mid; #endif -const char* g_version = "2.06 beta"; +const char* g_version = "2.06"; //----------------------------------------------------------------------------- // ASStreamIterator class @@ -1734,7 +1734,7 @@ void ASConsole::printHelp() const cout << " Insert space padding around operators.\n"; cout << endl; cout << " --pad-comma OR -xg\n"; - cout << " Insert space padding around commas and semicolons.\n"; + cout << " Insert space padding after commas.\n"; cout << endl; cout << " --pad-paren OR -P\n"; cout << " Insert space padding around parenthesis on both the outside\n"; diff --git a/NppAStyle/NppAStyleVersion.h b/NppAStyle/NppAStyleVersion.h index 62ae1c7..3057e0f 100644 --- a/NppAStyle/NppAStyleVersion.h +++ b/NppAStyle/NppAStyleVersion.h @@ -13,9 +13,9 @@ #define NPPASTYLE_NAME_STRING "NppAStyle" #define NPPASTYLE_FULLNAME_STRING "Artistic Style plugin for Notepad++" #define NPPASTYLE_AUTHOR_STRING "YWX" -#define NPPASTYLE_VERSION_STRING "0.2.4" -#define NPPASTYLE_VERSION_DIGITALVALUE 0,2,4 -#define NPPASTYLE_VERSION_RELEASEDATE "December 2016" -#define NPPASTYLE_VERSION_ASTYLE "Artistic Style 2.06 beta" +#define NPPASTYLE_VERSION_STRING "0.2.5" +#define NPPASTYLE_VERSION_DIGITALVALUE 0,2,5 +#define NPPASTYLE_VERSION_RELEASEDATE "January 2017" +#define NPPASTYLE_VERSION_ASTYLE "Artistic Style 2.06" #endif // _NPP_ASTYLE_VERSION_H diff --git a/readme.txt b/readme.txt index f4330d0..502dd5e 100644 --- a/readme.txt +++ b/readme.txt @@ -4,7 +4,7 @@ An Artistic Style plugin for Notepad++ to Format C, C++, C++/CLI, Objective-C, C Thanks to developers of Artistic Style, Scintilla and Notepad++. -NOTE: Artistic Style Version 2.06 beta +NOTE: Artistic Style Version 2.06 For information on Artistic Style, please see http://sourceforge.net/projects/astyle/ For information on Scintilla, please see http://www.scintilla.org/ or http://sourceforge.net/projects/scintilla/ For information on Notepad++, please see https://notepad-plus-plus.org/ or https://github.com/notepad-plus-plus/notepad-plus-plus @@ -178,7 +178,7 @@ Padding Options: Insert space padding around operators. pad comma - Insert space padding around commas and semicolons. + Insert space padding after commas. pad parenthesis outside Insert space padding around parenthesis on the outside only.