From 1bf0fd7d57751c95a29c15b36d8d9881cac1a615 Mon Sep 17 00:00:00 2001 From: Abe Jellinek Date: Wed, 15 May 2024 12:42:00 -0400 Subject: [PATCH] Scaffold: Manage blank lines before test cases automatically --- chrome/content/scaffold/scaffold.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/chrome/content/scaffold/scaffold.js b/chrome/content/scaffold/scaffold.js index 6e8f7e73a5..f7b561a8f0 100644 --- a/chrome/content/scaffold/scaffold.js +++ b/chrome/content/scaffold/scaffold.js @@ -691,7 +691,7 @@ var Scaffold = new function () { if (testStart !== -1 && testEnd !== -1) fixedCode = fixedCode.substr(0, testStart) + fixedCode.substr(testEnd + 23); // Convert whitespace to tabs - _editors.code.setValue(normalizeWhitespace(fixedCode)); + _editors.code.setValue(normalizeWhitespace(fixedCode.trimEnd())); // Then go to line 1 _editors.code.setPosition({ lineNumber: 1, column: 1 }); @@ -813,7 +813,7 @@ var Scaffold = new function () { var tests = _editors.tests.getValue().trim(); if (!tests || tests == '[]') tests = '[\n]'; // eslint wants a line break between the brackets - code += '/** BEGIN TEST CASES **/\nvar testCases = ' + tests + '\n/** END TEST CASES **/'; + code = code.trimEnd() + '\n\n/** BEGIN TEST CASES **/\nvar testCases = ' + tests + '\n/** END TEST CASES **/'; var metadata = _getMetadataObject(); if (metadata.label === "Untitled") {