diff --git a/README.md b/README.md index 31bf062..dca220d 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,10 @@ # What's new in Intouch-Language +### V1.2.1 + +- bugfix trailing whitespace before ``-`` + ### V1.2.0 - Add folding between ``{region xxxx}`` and ``{endregion xxxx}`` diff --git a/out/formats.js b/out/formats.js index 5d78c74..8fe49de 100644 --- a/out/formats.js +++ b/out/formats.js @@ -328,17 +328,19 @@ function forFormat(text, config) { for (j in const_2.SINGLE_OPERATORS) { if (text[i] === const_2.SINGLE_OPERATORS[j]) { if (const_2.SINGLE_OPERATORS[j] === "-") { - if (text[i + 1] === " " || text[i + 1] === const_1.TAB) { - //23.01.2022 check '-' as single Operator, because it can be used in variables + //23.01.2022 check '-' as single Operator, because it can be used in variables + let tstSwp = text[i + 1] == " " && text[i - 1] != " "; // 2022.01.25 Bugfix + let tstNmb = text[i + 1] == " " && text[i - 1] != " " && isNaN(+text[i + 1]); // 2022.01.25 Bugfix + if (tstSwp) { buf += " "; } } - else if (text[i - 1] !== " ") { + else if (text[i - 1] != " ") { //check for space before operator buf += " "; } buf += text[i]; - if (text[i + 1] !== " ") { + if (text[i + 1] != " ") { //check for space after operator // let debug1 = SINGLE_OPERATORS[j]; // if (SINGLE_OPERATORS[j] === '+' || SINGLE_OPERATORS[j] === '-') { diff --git a/package.json b/package.json index 4483a58..c4a24e5 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "intouch-language", "displayName": "Intouch-Language and Formatter for VSCode. (c)2021 vitalyruhl", "description": "Intouch-Language syntax highlighting, formatter and code snippets for VSCode", - "version": "1.2.0", + "version": "1.2.1", "icon": "images/logo.png", "publisher": "Vitaly-ruhl", "engines": { diff --git a/src/formats.ts b/src/formats.ts index 4848240..2ef4561 100644 --- a/src/formats.ts +++ b/src/formats.ts @@ -389,18 +389,20 @@ export function forFormat(text: string, config: any): string { for (j in SINGLE_OPERATORS) { if (text[i] === SINGLE_OPERATORS[j]) { if (SINGLE_OPERATORS[j] === "-") { - if (text[i + 1] === " " || text[i + 1] === TAB) { - //23.01.2022 check '-' as single Operator, because it can be used in variables + //23.01.2022 check '-' as single Operator, because it can be used in variables + let tstSwp = text[i + 1] == " " && text[i - 1] != " "; // 2022.01.25 Bugfix + let tstNmb = text[i + 1] == " " && text[i - 1] != " " && isNaN(+text[i + 1]); // 2022.01.25 Bugfix + if (tstSwp) { buf += " "; } - } else if (text[i - 1] !== " ") { + } else if (text[i - 1] != " ") { //check for space before operator buf += " "; } buf += text[i]; - if (text[i + 1] !== " ") { + if (text[i + 1] != " ") { //check for space after operator // let debug1 = SINGLE_OPERATORS[j]; // if (SINGLE_OPERATORS[j] === '+' || SINGLE_OPERATORS[j] === '-') { diff --git a/test/test.vbi b/test/test.vbi index 645ff4c..5ba0e4a 100644 --- a/test/test.vbi +++ b/test/test.vbi @@ -21,7 +21,7 @@ ITXStartAppInDirectory ( SYS_ToolsPath + "string ( with ) whitespaces test.", SY {region check single operators} SYS_Anlage = -1;{fixed 2021.10.29: no space on -/+ before Number!} -c=a+b +d- e+ f -g;{folowing comment not formated! -> c=a+b +d - e+ f;} +c=a+b +d- e+ f -g - x;{folowing comment not formated! -> c=a+b +d - e+ f;} {# New Region trenner} new12-issue-dashed-variable-123 = "this variable shal not be formated" {endregion check single operators}