isMalformedFileUri fix and tests

This commit is contained in:
Martin Aeschlimann
2018-08-09 12:03:23 +02:00
parent a4b28b833e
commit acf0d09f04
3 changed files with 36 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
'use strict';
import URI from 'vs/base/common/uri';
import { isMalformedFileUri } from 'vs/base/common/resources';
import * as vscode from 'vscode';
import * as typeConverters from 'vs/workbench/api/node/extHostTypeConverters';
import { CommandsRegistry, ICommandService, ICommandHandler } from 'vs/platform/commands/common/commands';
@@ -48,9 +49,11 @@ export class OpenFolderAPICommand {
if (!uri) {
return executor.executeCommand('_files.pickFolderAndOpen', forceNewWindow);
}
if (!uri.scheme) {
console.warn(`'vscode.openFolder' command invoked with an invalid URI (scheme missing): '${uri}'. Converted to a 'file://' URI.`);
uri = URI.file(uri.toString());
let correctedUri = isMalformedFileUri(uri);
if (correctedUri) {
// workaround for #55916 and #55891, will be removed in 1.28
console.warn(`'vscode.openFolder' command invoked with an invalid URI (file:// scheme missing): '${uri}'. Converted to a 'file://' URI: ${correctedUri}`);
uri = correctedUri;
}
return executor.executeCommand('_files.windowOpen', [uri], forceNewWindow);