mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
use correct uri manipulation, #25539
This commit is contained in:
@@ -85,6 +85,13 @@ suite('workspace-namespace', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('openTextDocument, untitled with host', function () {
|
||||
const uri = Uri.parse('untitled://localhost/c%24/Users/jrieken/code/samples/foobar.txt');
|
||||
return workspace.openTextDocument(uri).then(doc => {
|
||||
assert.equal(doc.uri.scheme, 'untitled');
|
||||
});
|
||||
});
|
||||
|
||||
test('openTextDocument, untitled without path', function () {
|
||||
return workspace.openTextDocument().then(doc => {
|
||||
assert.equal(doc.uri.scheme, 'untitled');
|
||||
|
||||
@@ -227,7 +227,7 @@ export class MainThreadDocuments extends MainThreadDocumentsShape {
|
||||
}
|
||||
|
||||
private _handleUnititledScheme(uri: URI): TPromise<boolean> {
|
||||
let asFileUri = URI.file(uri.fsPath);
|
||||
let asFileUri = uri.with({ scheme: 'file' });
|
||||
return this._fileService.resolveFile(asFileUri).then(stats => {
|
||||
// don't create a new file ontop of an existing file
|
||||
return TPromise.wrapError<boolean>('file already exists on disk');
|
||||
|
||||
@@ -161,7 +161,7 @@ export class UntitledEditorService implements IUntitledEditorService {
|
||||
let hasAssociatedFilePath = false;
|
||||
if (resource) {
|
||||
hasAssociatedFilePath = (resource.scheme === 'file');
|
||||
resource = this.resourceToUntitled(resource); // ensure we have the right scheme
|
||||
resource = resource.with({ scheme: UntitledEditorInput.SCHEMA }); // ensure we have the right scheme
|
||||
|
||||
if (hasAssociatedFilePath) {
|
||||
UntitledEditorService.KNOWN_ASSOCIATED_FILE_PATHS.set(resource, true); // remember for future lookups
|
||||
@@ -231,14 +231,6 @@ export class UntitledEditorService implements IUntitledEditorService {
|
||||
return input;
|
||||
}
|
||||
|
||||
private resourceToUntitled(resource: URI): URI {
|
||||
if (resource.scheme === UntitledEditorInput.SCHEMA) {
|
||||
return resource;
|
||||
}
|
||||
|
||||
return URI.from({ scheme: UntitledEditorInput.SCHEMA, path: resource.fsPath });
|
||||
}
|
||||
|
||||
public hasAssociatedFilePath(resource: URI): boolean {
|
||||
return UntitledEditorService.KNOWN_ASSOCIATED_FILE_PATHS.has(resource);
|
||||
}
|
||||
@@ -249,4 +241,4 @@ export class UntitledEditorService implements IUntitledEditorService {
|
||||
this._onDidChangeEncoding.dispose();
|
||||
this._onDidDisposeModel.dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user