mirror of
https://github.com/letscontrolit/ESPEasy.git
synced 2026-07-27 19:57:38 +00:00
no indentation for comments....
This commit is contained in:
+13
-4
@@ -283,8 +283,11 @@ function initalAutocorrection() {
|
||||
|
||||
function formatLogic(text) {
|
||||
const INDENT = ' '; // 2 spaces
|
||||
const lines = text.split('\n').map(line => line.trim()); // remove all existing indentation
|
||||
|
||||
const lines = text.split('\n').map(line => {
|
||||
const trimmed = line.trimStart(); // remove leading spaces only
|
||||
return trimmed.startsWith('//') ? line : trimmed;
|
||||
});
|
||||
|
||||
let indentLevel = 0;
|
||||
const result = [];
|
||||
const stack = [];
|
||||
@@ -383,8 +386,14 @@ function formatLogic(text) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// any normal line inside On block
|
||||
result.push(INDENT.repeat(indentLevel) + line);
|
||||
if (line.trim().startsWith('//')) {
|
||||
// no indentation for comments
|
||||
result.push(line);
|
||||
} else {
|
||||
// any normal line inside On block
|
||||
result.push(INDENT.repeat(indentLevel) + line);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user