Skip to content

Commit fee5628

Browse files
Fix prevent unwanted semicolon insertion (#13)
Fix unwanted semicolon insertion in ObjectScript dot-prefixed blocks: auto-continuation now inserts the copied prefix only when the target line is empty and preserves ; only if it existed on the previous line, and a regression test ensures moving lines across dot-prefixed semicolon comments does not inject semicolons.
1 parent bd7bddd commit fee5628

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/extension.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1098,6 +1098,9 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
10981098
}
10991099

11001100
const newLine = event.document.lineAt(newLineNumber);
1101+
if (newLine.text.trim().length > 0) {
1102+
continue;
1103+
}
11011104
if (newLine.text.startsWith(insertText)) {
11021105
continue;
11031106
}

src/test/suite/extension.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,22 @@ suite("Extension Test Suite", () => {
9191
}
9292
});
9393

94+
test("Moving lines across dot-prefixed semicolon comments doesn't add semicolons", async () => {
95+
const document = await vscode.workspace.openTextDocument({
96+
language: "objectscript",
97+
content: " . Do ##class(Test).Run()\n . ; Comment",
98+
});
99+
const editor = await vscode.window.showTextDocument(document);
100+
try {
101+
editor.selection = new vscode.Selection(new vscode.Position(0, 0), new vscode.Position(0, 0));
102+
await vscode.commands.executeCommand("editor.action.moveLinesDownAction");
103+
const expectedText = " . ; Comment\n . Do ##class(Test).Run()";
104+
await waitForCondition(() => document.getText() === expectedText);
105+
assert.strictEqual(document.getText(), expectedText);
106+
} finally {
107+
await vscode.commands.executeCommand("workbench.action.closeActiveEditor");
108+
}
109+
});
94110
test("Go to Definition resolves to sibling workspace folder", async function () {
95111
this.timeout(10000);
96112
await waitForIndexedDocument("MultiRoot.Shared.cls", "shared");

0 commit comments

Comments
 (0)