setup uri properly and also make the doc more clear, fixes #4315

This commit is contained in:
Johannes Rieken
2016-03-17 10:43:28 +01:00
parent b3a1ec60a8
commit 32bd7fd3ee
2 changed files with 4 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
import * as vscode from 'vscode';
import {ITypescriptServiceClient} from '../typescriptService';
import {loadMessageBundle} from 'vscode-nls';
import {dirname} from 'path';
import {dirname, join} from 'path';
const localize = loadMessageBundle();
const selector = ['javascript', 'javascriptreact'];
@@ -88,7 +88,7 @@ export function create(client: ITypescriptServiceClient, memento: vscode.Memento
projectHinted[configFileName] = true;
item.hide();
return vscode.workspace.openTextDocument(vscode.Uri.parse('untitled://' + vscode.workspace.rootPath + '/jsconfig.json'))
return vscode.workspace.openTextDocument(vscode.Uri.parse('untitled:' + join(vscode.workspace.rootPath, 'jsconfig.json')))
.then(vscode.window.showTextDocument)
.then(editor => editor.edit(builder => builder.insert(new vscode.Position(0, 0), defaultConfig)));
}

4
src/vs/vscode.d.ts vendored
View File

@@ -3213,8 +3213,8 @@ declare namespace vscode {
* [open document](#workspace.onDidOpenTextDocument)-event fires.
* The document to open is denoted by the [uri](#Uri). Two schemes are supported:
*
* file: A file on disk, will be rejected if the file does not exist or cannot be loaded, e.g. 'file:///Users/frodo/r.ini'.
* untitled: A new file that should be saved on disk, e.g. 'untitled:/Users/frodo/new.js'. The language will be derived from the file name.
* file: A file on disk, will be rejected if the file does not exist or cannot be loaded, e.g. `file:///Users/frodo/r.ini`.
* untitled: A new file that should be saved on disk, e.g. `untitled:c:\frodo\new.js`. The language will be derived from the file name.
*
* Uris with other schemes will make this method return a rejected promise.
*