Minor code review

This commit is contained in:
Raymond Hill 2020-01-23 12:06:40 -05:00
parent 9637ab56a9
commit 2e0a8951b8
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 10 additions and 10 deletions

View File

@ -83,19 +83,19 @@ const renderAdvancedSettings = async function(first) {
}); });
beforeHash = hashFromAdvancedSettings(raw); beforeHash = hashFromAdvancedSettings(raw);
let pretty = [], const pretty = [];
whitespaces = ' ', const lines = raw.split('\n');
lines = raw.split('\n'), let max = 0;
max = 0; for ( const line of lines ) {
for ( let line of lines ) { const pos = line.indexOf(' ');
let pos = line.indexOf(' ');
if ( pos > max ) { max = pos; } if ( pos > max ) { max = pos; }
} }
for ( let line of lines ) { for ( const line of lines ) {
let pos = line.indexOf(' '); const pos = line.indexOf(' ');
pretty.push(whitespaces.slice(0, max - pos) + line); pretty.push(' '.repeat(max - pos) + line);
} }
cmEditor.setValue(pretty.join('\n') + '\n'); pretty.push('');
cmEditor.setValue(pretty.join('\n'));
if ( first ) { if ( first ) {
cmEditor.clearHistory(); cmEditor.clearHistory();
} }