diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/Lang/Cpp/CppParser.ts | 10 | ||||
| -rw-r--r-- | src/test/CppTests/Preprocessor.test.ts | 19 |
2 files changed, 24 insertions, 5 deletions
diff --git a/src/Lang/Cpp/CppParser.ts b/src/Lang/Cpp/CppParser.ts index 708af68..61a4d76 100644 --- a/src/Lang/Cpp/CppParser.ts +++ b/src/Lang/Cpp/CppParser.ts @@ -426,19 +426,19 @@ export default class CppParser implements ICodeParser { if (nextLineTxt.startsWith("#include")) { this.commentType = CommentType.file; return ""; - } else if (nextLineTxt.startsWith("#")) { // preprocessor stuff - this.commentType = CommentType.method; - return "#"; } - if (!this.isVsCodeAutoComplete(nextLineTxt)) { + if (this.isVsCodeAutoComplete(nextLineTxt) === true) { + // Can only be true if it's in the next line + this.vscodeAutoGeneratedComment = linesToGet === (this.cfg.Generic.linesToGet - 1); + } else { logicalLine += "\n"; if (finalSlice >= 0) { logicalLine += nextLineTxt.slice(0, finalSlice); } else { logicalLine += nextLineTxt; } - logicalLine.replace(/\*\//g, ""); + logicalLine = logicalLine.replace(/\*\//g, ""); } if (finalSlice >= 0) { diff --git a/src/test/CppTests/Preprocessor.test.ts b/src/test/CppTests/Preprocessor.test.ts index c89a80a..7e4708b 100644 --- a/src/test/CppTests/Preprocessor.test.ts +++ b/src/test/CppTests/Preprocessor.test.ts @@ -30,4 +30,23 @@ suite("C++ - Preprocessor Tests", () => { ]).GetResult(); assert.equal("/**\n * @brief \n * \n */", result); }); + + // These two tests don't seem to belong here but the behavior they're testing only is reproducable + // for macros otherwise + test("detect auto generated closing */", () => { + const result = testSetup.SetLines([ + "*/", // simulate an auto generated closing block comment + "void foo(int bar);", + ]).GetResult(); + assert.equal("/**\n * @brief \n * \n * @param bar \n */", result); + }); + + test("don't detect closing */", () => { + const result = testSetup.SetLines([ + "/*", + " */", + "void foo(int bar);", + ]).GetResult(); + assert.equal("/**\n * @brief \n * \n */", result); + }); }); |