From 2e0a8951b8c3b1963d1b26e7de0a6b2fc7e887fd Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Thu, 23 Jan 2020 12:06:40 -0500 Subject: [PATCH] Minor code review --- src/js/advanced-settings.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/js/advanced-settings.js b/src/js/advanced-settings.js index ce92f3b1b..940a12887 100644 --- a/src/js/advanced-settings.js +++ b/src/js/advanced-settings.js @@ -83,19 +83,19 @@ const renderAdvancedSettings = async function(first) { }); beforeHash = hashFromAdvancedSettings(raw); - let pretty = [], - whitespaces = ' ', - lines = raw.split('\n'), - max = 0; - for ( let line of lines ) { - let pos = line.indexOf(' '); + const pretty = []; + const lines = raw.split('\n'); + let max = 0; + for ( const line of lines ) { + const pos = line.indexOf(' '); if ( pos > max ) { max = pos; } } - for ( let line of lines ) { - let pos = line.indexOf(' '); - pretty.push(whitespaces.slice(0, max - pos) + line); + for ( const line of lines ) { + const pos = line.indexOf(' '); + pretty.push(' '.repeat(max - pos) + line); } - cmEditor.setValue(pretty.join('\n') + '\n'); + pretty.push(''); + cmEditor.setValue(pretty.join('\n')); if ( first ) { cmEditor.clearHistory(); }