@@ -21,6 +21,17 @@ async function waitForIndexedDocument(documentName: string, workspaceFolderName:
2121 assert . fail ( `Timed out waiting for '${ documentName } ' to be indexed in workspace folder '${ workspaceFolderName } '.` ) ;
2222}
2323
24+ async function waitForCondition ( predicate : ( ) => boolean , timeoutMs = 1000 , message ?: string ) : Promise < void > {
25+ const start = Date . now ( ) ;
26+ while ( Date . now ( ) - start < timeoutMs ) {
27+ if ( predicate ( ) ) {
28+ return ;
29+ }
30+ await new Promise ( ( resolve ) => setTimeout ( resolve , 10 ) ) ;
31+ }
32+ assert . fail ( message ?? "Timed out waiting for condition" ) ;
33+ }
34+
2435function getDefinitionTargets ( definitions : ( vscode . Location | vscode . DefinitionLink ) [ ] ) : vscode . Uri [ ] {
2536 return definitions
2637 . map ( ( definition ) => ( "targetUri" in definition ? definition . targetUri : definition . uri ) )
@@ -44,6 +55,42 @@ suite("Extension Test Suite", () => {
4455 assert . ok ( "All good" ) ;
4556 } ) ;
4657
58+ test ( "Dot-prefixed statements continue on newline" , async ( ) => {
59+ const document = await vscode . workspace . openTextDocument ( {
60+ language : "objectscript" ,
61+ content : " . Do ##class(Test).Run()" ,
62+ } ) ;
63+ const editor = await vscode . window . showTextDocument ( document ) ;
64+ try {
65+ await editor . edit ( ( editBuilder ) => {
66+ editBuilder . insert ( document . lineAt ( 0 ) . range . end , "\n" ) ;
67+ } ) ;
68+ await waitForCondition ( ( ) => document . lineCount > 1 ) ;
69+ await waitForCondition ( ( ) => document . lineAt ( 1 ) . text . length > 0 ) ;
70+ assert . strictEqual ( document . lineAt ( 1 ) . text , " . " ) ;
71+ } finally {
72+ await vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" ) ;
73+ }
74+ } ) ;
75+
76+ test ( "Dot-prefixed semicolon comments continue on newline" , async ( ) => {
77+ const document = await vscode . workspace . openTextDocument ( {
78+ language : "objectscript" ,
79+ content : " . ; Comment" ,
80+ } ) ;
81+ const editor = await vscode . window . showTextDocument ( document ) ;
82+ try {
83+ await editor . edit ( ( editBuilder ) => {
84+ editBuilder . insert ( document . lineAt ( 0 ) . range . end , "\n" ) ;
85+ } ) ;
86+ await waitForCondition ( ( ) => document . lineCount > 1 ) ;
87+ await waitForCondition ( ( ) => document . lineAt ( 1 ) . text . length > 0 ) ;
88+ assert . strictEqual ( document . lineAt ( 1 ) . text , " . ;" ) ;
89+ } finally {
90+ await vscode . commands . executeCommand ( "workbench.action.closeActiveEditor" ) ;
91+ }
92+ } ) ;
93+
4794 test ( "Go to Definition resolves to sibling workspace folder" , async function ( ) {
4895 this . timeout ( 10000 ) ;
4996 await waitForIndexedDocument ( "MultiRoot.Shared.cls" , "shared" ) ;
0 commit comments