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

💄

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