Skip to content

Commit 9fc6310

Browse files
committed
fixed indention issue in autoformatting, closes #122
1 parent f3b7c43 commit 9fc6310

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/providers/DocumentFormattingEditProvider.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export class DocumentFormattingEditProvider implements vscode.DocumentFormatting
3232
const line = document.lineAt(i);
3333
const text = this.stripLineComments(line.text);
3434

35+
if (!text.replace(/[\s\t]+/g, "").length) {
36+
continue;
37+
}
38+
3539
if (text.match(/<script .*>/)) {
3640
jsScript = true;
3741
}
@@ -229,9 +233,8 @@ export class DocumentFormattingEditProvider implements vscode.DocumentFormatting
229233
const [, found, isFunc] = functionsMatch;
230234
const pos = functionsMatch.index;
231235
const range = new vscode.Range(new vscode.Position(i, pos), new vscode.Position(i, pos + found.length));
232-
const systemFunction = (isFunc ? systemFunctions : systemVariables).find(el =>
233-
el.alias.includes(found.toUpperCase())
234-
);
236+
const list: any[] = isFunc ? systemFunctions : systemVariables;
237+
const systemFunction = list.find(el => el.alias.includes(found.toUpperCase()));
235238
if (systemFunction) {
236239
const expect = this._formatter.function(systemFunction.label);
237240
if (expect !== found) {

src/utils/index.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,11 @@ export function currentFile(document?: vscode.TextDocument): CurrentFile {
5656
}
5757
} else {
5858
const match = content.match(/^ROUTINE ([^\s]+)(?:\s+\[.*Type=([a-z]{3,}))?/i);
59-
[, name, ext = "mac"] = match;
59+
if (match) {
60+
[, name, ext = "mac"] = match;
61+
} else {
62+
[name, ext = "mac"] = path.basename(document.fileName).split(".");
63+
}
6064
}
6165
if (!name) {
6266
return null;
@@ -188,7 +192,7 @@ export function terminalWithDocker() {
188192
service,
189193
"/bin/bash",
190194
"-c",
191-
`command -v ccontrol >/dev/null 2>&1 && (ccontrol session $ISC_PACKAGE_INSTANCENAME -U ${ns} || iris session $ISC_PACKAGE_INSTANCENAME -U ${ns})`,
195+
`command -v iris >/dev/null 2>&1 && iris session $ISC_PACKAGE_INSTANCENAME -U ${ns} || ccontrol session $ISC_PACKAGE_INSTANCENAME -U ${ns}`,
192196
]);
193197
}
194198
terminal.show();

0 commit comments

Comments
 (0)