提交 7b8d42c3 编写于 作者: B Benjamin Pasero

💄

上级 85d4bf7a
......@@ -33,6 +33,7 @@ import { coalesce } from 'vs/base/common/arrays';
import { ServicesAccessor, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { getCodeEditor } from 'vs/editor/browser/services/codeEditorService';
import { IEditorIdentifier } from 'vs/workbench/common/editor';
import { basenameOrAuthority } from 'vs/base/common/resources';
export interface IDraggedResource {
resource: URI;
......@@ -177,7 +178,7 @@ export class ResourcesDropHandler {
}
// Add external ones to recently open list unless dropped resource is a workspace
const resourcesToAddToHistory = untitledOrFileResources.filter(d => d.isExternal && d.resource.scheme !== Schemas.untitled).map(d => d.resource);
const resourcesToAddToHistory = untitledOrFileResources.filter(d => d.isExternal && d.resource.scheme === Schemas.file).map(d => d.resource);
if (resourcesToAddToHistory.length) {
this.windowsService.addRecentlyOpened(resourcesToAddToHistory.map(resource => resource.fsPath));
}
......@@ -331,7 +332,7 @@ export class SimpleFileResourceDragAndDrop extends DefaultDragAndDrop {
const resource = this.toResource(elements[0]);
if (resource) {
return basename(resource.fsPath);
return basenameOrAuthority(resource);
}
return void 0;
......
......@@ -102,7 +102,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
});
// Editor Title Context Menu
appendEditorTitleContextMenuItem(REVEAL_IN_OS_COMMAND_ID, REVEAL_IN_OS_LABEL, ResourceContextKey.Scheme.isEqualTo('file'));
appendEditorTitleContextMenuItem(REVEAL_IN_OS_COMMAND_ID, REVEAL_IN_OS_LABEL, ResourceContextKey.Scheme.isEqualTo(Schemas.file));
appendEditorTitleContextMenuItem(COPY_PATH_COMMAND_ID, CopyPathAction.LABEL, ResourceContextKey.IsFile);
appendEditorTitleContextMenuItem(REVEAL_IN_EXPLORER_COMMAND_ID, nls.localize('revealInSideBar', "Reveal in Side Bar"), ResourceContextKey.IsFile);
......@@ -187,7 +187,7 @@ MenuRegistry.appendMenuItem(MenuId.OpenEditorsContext, {
group: 'navigation',
order: 20,
command: revealInOsCommand,
when: ResourceContextKey.Scheme.isEqualTo('file')
when: ResourceContextKey.Scheme.isEqualTo(Schemas.file)
});
const copyPathCommand = {
......@@ -356,7 +356,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
group: 'navigation',
order: 20,
command: revealInOsCommand,
when: ResourceContextKey.Scheme.isEqualTo('file')
when: ResourceContextKey.Scheme.isEqualTo(Schemas.file)
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
......
......@@ -422,7 +422,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
function resourcesToClipboard(resources: URI[], clipboardService: IClipboardService, messageService: IMessageService): void {
if (resources.length) {
const lineDelimiter = isWindows ? '\r\n' : '\n';
const text = resources.map(r => r.scheme === 'file' ? labels.getPathLabel(r) : r.toString()).join(lineDelimiter);
const text = resources.map(r => r.scheme === Schemas.file ? labels.getPathLabel(r) : r.toString()).join(lineDelimiter);
clipboardService.writeText(text);
} else {
messageService.show(severity.Info, nls.localize('openFileToCopy', "Open a file first to copy its path"));
......
......@@ -233,7 +233,7 @@ MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
id: FIND_IN_FOLDER_ID,
title: nls.localize('findInFolder', "Find in Folder...")
},
when: ContextKeyExpr.and(ExplorerFolderContext, ResourceContextKey.Scheme.isEqualTo('file'))
when: ContextKeyExpr.and(ExplorerFolderContext, ResourceContextKey.Scheme.isEqualTo('file')) // todo@remote
});
MenuRegistry.appendMenuItem(MenuId.ExplorerContext, {
......
......@@ -20,6 +20,7 @@ import { ICodeEditor } from 'vs/editor/browser/editorBrowser';
import { relative } from 'path';
import { IProcessEnvironment, isWindows } from 'vs/base/common/platform';
import { normalizeDriveLetter } from 'vs/base/common/labels';
import { Schemas } from 'vs/base/common/network';
class VariableResolver {
static VARIABLE_REGEXP = /\$\{(.*?)\}/g;
......@@ -145,7 +146,7 @@ class VariableResolver {
input = input.modifiedInput;
}
const fileResource = toResource(input, { filter: 'file' });
const fileResource = toResource(input, { filter: Schemas.file });
if (!fileResource) {
return undefined;
}
......
......@@ -9,7 +9,6 @@ import { TPromise } from 'vs/base/common/winjs.base';
import { createDecorator, ServiceIdentifier, IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IEditorService, IEditor, IEditorInput, IEditorOptions, ITextEditorOptions, Position, Direction, IResourceInput, IResourceDiffInput, IResourceSideBySideInput, IUntitledResourceInput } from 'vs/platform/editor/common/editor';
import URI from 'vs/base/common/uri';
import network = require('vs/base/common/network');
import { Registry } from 'vs/platform/registry/common/platform';
import { basename, dirname } from 'vs/base/common/paths';
import { EditorInput, EditorOptions, TextEditorOptions, Extensions as EditorExtensions, SideBySideEditorInput, IFileEditorInput, IFileInputFactory, IEditorInputFactoryRegistry } from 'vs/workbench/common/editor';
......@@ -192,7 +191,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
const resourceInput = <IResourceInput>input;
if (resourceInput.resource instanceof URI) {
const schema = resourceInput.resource.scheme;
if (schema === network.Schemas.http || schema === network.Schemas.https) {
if (schema === Schemas.http || schema === Schemas.https) {
window.open(resourceInput.resource.toString(true));
return TPromise.wrap<IEditor>(null);
......@@ -322,7 +321,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
const resourceInput = <IResourceInput>input;
// Files / Data URI support
if (resourceInput.resource instanceof URI && (resourceInput.resource.scheme === network.Schemas.file || resourceInput.resource.scheme === network.Schemas.data)) {
if (resourceInput.resource instanceof URI && (resourceInput.resource.scheme === Schemas.file || resourceInput.resource.scheme === Schemas.data)) {
return this.createOrGet(resourceInput.resource, this.instantiationService, resourceInput.label, resourceInput.description, resourceInput.encoding);
}
......@@ -332,7 +331,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
let description: string;
if (typeof resourceInput.description === 'string') {
description = resourceInput.description;
} else if (resourceInput.resource.scheme === network.Schemas.file) {
} else if (resourceInput.resource.scheme === Schemas.file) {
description = dirname(resourceInput.resource.fsPath);
}
......@@ -358,12 +357,12 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
let input: ICachedEditorInput;
// File
if (resource.scheme === network.Schemas.file || this.fileService.canHandleResource(resource)) {
if (this.fileService.canHandleResource(resource)) {
input = this.fileInputFactory.createFileInput(resource, encoding, instantiationService);
}
// Data URI
else if (resource.scheme === network.Schemas.data) {
else if (resource.scheme === Schemas.data) {
input = instantiationService.createInstance(DataUriEditorInput, label, description, resource);
}
......
......@@ -26,6 +26,7 @@ import { shell } from 'electron';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { isMacintosh } from 'vs/base/common/platform';
import product from 'vs/platform/node/product';
import { Schemas } from 'vs/base/common/network';
export class FileService implements IFileService {
......@@ -243,7 +244,7 @@ export class FileService implements IFileService {
return;
}
if (resource.scheme !== 'file') {
if (resource.scheme !== Schemas.file) {
return; // only support files
}
......
......@@ -42,6 +42,7 @@ import { getBaseLabel } from 'vs/base/common/labels';
import { assign } from 'vs/base/common/objects';
import { Readable } from 'stream';
import { IWriteFileOptions } from 'vs/base/node/extfs';
import { Schemas } from 'vs/base/common/network';
export interface IEncodingOverride {
resource: uri;
......@@ -260,7 +261,7 @@ export class FileService implements IFileService {
public resolveStreamContent(resource: uri, options?: IResolveContentOptions): TPromise<IStreamContent> {
// Guard early against attempts to resolve an invalid file path
if (resource.scheme !== 'file' || !resource.fsPath) {
if (resource.scheme !== Schemas.file || !resource.fsPath) {
return TPromise.wrapError<IStreamContent>(new FileOperationError(
nls.localize('fileInvalidPath', "Invalid file resource ({0})", resource.toString(true)),
FileOperationResult.FILE_INVALID_PATH,
......@@ -881,7 +882,7 @@ export class FileService implements IFileService {
resource = (<IFileStat>arg1).resource;
}
assert.ok(resource && resource.scheme === 'file', 'Invalid resource: ' + resource);
assert.ok(resource && resource.scheme === Schemas.file, `Invalid resource: ${resource}`);
return paths.normalize(resource.fsPath);
}
......@@ -1018,7 +1019,7 @@ export class FileService implements IFileService {
}
public watchFileChanges(resource: uri): void {
assert.ok(resource && resource.scheme === 'file', `Invalid resource for watching: ${resource}`);
assert.ok(resource && resource.scheme === Schemas.file, `Invalid resource for watching: ${resource}`);
// Create or get watcher for provided path
let watcher = this.activeFileChangesWatchers.get(resource);
......@@ -1137,7 +1138,7 @@ export class StatResolver {
private errorLogger: (error: Error | string) => void;
constructor(resource: uri, isDirectory: boolean, mtime: number, size: number, errorLogger?: (error: Error | string) => void) {
assert.ok(resource && resource.scheme === 'file', 'Invalid resource: ' + resource);
assert.ok(resource && resource.scheme === Schemas.file, `Invalid resource: ${resource}`);
this.resource = resource;
this.isDirectory = isDirectory;
......
......@@ -30,6 +30,7 @@ import { IExpression } from 'vs/base/common/glob';
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { ResourceGlobMatcher } from 'vs/workbench/electron-browser/resources';
import { Schemas } from 'vs/base/common/network';
/**
* Stores the selection & view state of an editor and allows to compare it to other selection states.
......@@ -808,12 +809,12 @@ export class HistoryService implements IHistoryService {
const input = history[i];
if (input instanceof EditorInput) {
resource = toResource(input, { filter: 'file' });
resource = toResource(input, { filter: Schemas.file });
} else {
resource = (input as IResourceInput).resource;
}
if (resource && resource.scheme === 'file') {
if (resource && resource.scheme === Schemas.file) {
return resource;
}
}
......
......@@ -168,7 +168,7 @@ export class SearchService implements ISearchService {
// todo@remote
// why is that? we should search for resources from other
// schemes
else if (resource.scheme !== 'file') {
else if (resource.scheme !== Schemas.file) {
return;
}
......@@ -197,7 +197,7 @@ export class SearchService implements ISearchService {
private matches(resource: uri, query: ISearchQuery): boolean {
// file pattern
if (query.filePattern) {
if (resource.scheme !== 'file') {
if (resource.scheme !== Schemas.file) {
return false; // if we match on file pattern, we have to ignore non file resources
}
......@@ -208,7 +208,7 @@ export class SearchService implements ISearchService {
// includes
if (query.includePattern) {
if (resource.scheme !== 'file') {
if (resource.scheme !== Schemas.file) {
return false; // if we match on file patterns, we have to ignore non file resources
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册