@@ -18,7 +18,7 @@ import { DebugProtocol } from "vscode-debugprotocol";
18
18
import WebSocket = require( "ws" ) ;
19
19
import { AtelierAPI } from "../api" ;
20
20
import * as xdebug from "./xdebugConnection" ;
21
- import { schemas } from "../extension" ;
21
+ import { documentContentProvider , OBJECTSCRIPT_FILE_SCHEMA , schemas } from "../extension" ;
22
22
import { DocumentContentProvider } from "../providers/DocumentContentProvider" ;
23
23
import { formatPropertyValue } from "./utils" ;
24
24
@@ -38,6 +38,15 @@ interface AttachRequestArguments extends DebugProtocol.AttachRequestArguments {
38
38
stopOnEntry ?: boolean ;
39
39
}
40
40
41
+ /** Get the text of file `uri`. Works for all file systems and the `objectscript` `DocumentContentProvider`. */
42
+ async function getFileText ( uri : vscode . Uri ) : Promise < string > {
43
+ if ( uri . scheme == OBJECTSCRIPT_FILE_SCHEMA ) {
44
+ return await documentContentProvider . provideTextDocumentContent ( uri , new vscode . CancellationTokenSource ( ) . token ) ;
45
+ } else {
46
+ return new TextDecoder ( ) . decode ( await vscode . workspace . fs . readFile ( uri ) ) ;
47
+ }
48
+ }
49
+
41
50
/** converts a uri from VS Code to a server-side XDebug file URI with respect to source root settings */
42
51
async function convertClientPathToDebugger ( uri : vscode . Uri , namespace : string ) : Promise < string > {
43
52
const { scheme, path } = uri ;
@@ -49,7 +58,7 @@ async function convertClientPathToDebugger(uri: vscode.Uri, namespace: string):
49
58
}
50
59
fileName = path . slice ( 1 ) . replace ( / \/ / g, "." ) ;
51
60
} else {
52
- fileName = currentFileFromContent ( uri , new TextDecoder ( ) . decode ( await vscode . workspace . fs . readFile ( uri ) ) ) ?. name ;
61
+ fileName = currentFileFromContent ( uri , await getFileText ( uri ) ) ?. name ;
53
62
}
54
63
55
64
namespace = encodeURIComponent ( namespace ) ;
@@ -303,7 +312,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
303
312
currentSymbol . detail . toLowerCase ( ) !== "query"
304
313
) {
305
314
// This breakpoint is in a method
306
- const currentdoc = new TextDecoder ( ) . decode ( await vscode . workspace . fs . readFile ( uri ) ) . split ( / \r ? \n / ) ;
315
+ const currentdoc = ( await getFileText ( uri ) ) . split ( / \r ? \n / ) ;
307
316
if ( languageServer ) {
308
317
// selectionRange.start.line is the method definition line
309
318
for (
@@ -536,7 +545,7 @@ export class ObjectScriptDebugSession extends LoggingDebugSession {
536
545
}
537
546
}
538
547
if ( currentSymbol !== undefined ) {
539
- const currentdoc = new TextDecoder ( ) . decode ( await vscode . workspace . fs . readFile ( fileUri ) ) . split ( / \r ? \n / ) ;
548
+ const currentdoc = ( await getFileText ( fileUri ) ) . split ( / \r ? \n / ) ;
540
549
if ( languageServer ) {
541
550
for (
542
551
let methodlinenum = currentSymbol . selectionRange . start . line ;
0 commit comments