Shan Khan Shan Khan - 1 year ago 144
Node.js Question

string unable to parse in URI in vscode API

Console LOG shows : \Users\skhan\Library\Application Support\Code\User\summary.txt

as loop is using to replace the slashes

its working fine in windows but doesnt work in ubuntu and mac, this is the example of OSX 10.11.6

But when i try to parse URI using API i get the following error

threadService.ts:217[Extension Host] cannot open untitled:%5CUsers%5Cjdoe%5CLibrary%5CApplication%20Support%5CCode%5CUser%5Csummary.txt. Detail: expected URI untitled:%5CUsers%5Cjdoet%5CLibrary%5CApplication%20Support%5CCode%5CUser%5Csummary.txt BUT GOT untitled:/Users/jdoe/Library/Application%20Support/Code/User/summary.txt(anonymous function) @ threadService.ts:217

Following is the code


while (tempURI.indexOf("/") > -1) {
tempURI = tempURI.replace("/", "\\");

console.log("FILE URI For Summary Page : " + tempURI);

var setting: vscode.Uri = vscode.Uri.parse("untitled:" + tempURI); //ERROR HERE

vscode.workspace.openTextDocument(setting).then((a: vscode.TextDocument) => { ...


Is there anythings more i have do to parse in correct URI ?

Answer Source

I used uri.parse.file to make it file and all things worked as expected

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download