From a5b9a5497abd07c157c8faa5af17a3a16ffe90ad Mon Sep 17 00:00:00 2001 From: Christoph Schlosser Date: Tue, 8 Oct 2019 21:52:10 +0200 Subject: =?UTF-8?q?Don=E2=80=99t=20use=20unnecessary=20variables?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Lang/Cpp/CppParser.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Lang/Cpp/CppParser.ts b/src/Lang/Cpp/CppParser.ts index 3b13721..dcdfcba 100644 --- a/src/Lang/Cpp/CppParser.ts +++ b/src/Lang/Cpp/CppParser.ts @@ -400,8 +400,7 @@ export default class CppParser implements ICodeParser { while (linesToGet-- > 0) { // Check for end of expression. nextLine = new Position(nextLine.line + 1, nextLine.character); nextLineTxt = this.activeEditor.document.lineAt(nextLine.line).text.trim(); - let finalSlice = 0; - let endOfDeclaration = false; + let finalSlice = -1; // Check if method has finished if curly brace is opened while // nesting is occuring. @@ -412,13 +411,11 @@ export default class CppParser implements ICodeParser { currentNest--; } else if (nextLineTxt[i] === "{" && currentNest === 0) { finalSlice = i; - endOfDeclaration = true; break; } else if ((nextLineTxt[i] === ";" || (nextLineTxt[i] === ":" && nextLineTxt[i - 1] !== ":" && nextLineTxt[i + 1] !== ":")) && currentNest === 0) { finalSlice = i; - endOfDeclaration = true; break; } } @@ -431,7 +428,7 @@ export default class CppParser implements ICodeParser { if (!this.isVsCodeAutoComplete(nextLineTxt)) { logicalLine += "\n"; - if (endOfDeclaration === true) { + if (finalSlice >= 0) { logicalLine += nextLineTxt.slice(0, finalSlice); } else { logicalLine += nextLineTxt; @@ -439,7 +436,7 @@ export default class CppParser implements ICodeParser { logicalLine.replace(/\*\//g, ""); } - if (endOfDeclaration) { + if (finalSlice >= 0) { return logicalLine.replace(/^\s+|\s+$/g, ""); } } -- cgit v1.2.3