提交 e134f42a 编写于 作者: B Benjamin Pasero

follow up 💄 on #12448

上级 6159f870
......@@ -443,6 +443,13 @@ export class ResourceMap<T> {
this.map.forEach(clb);
}
public values(): T[] {
const values: T[] = [];
this.map.forEach(value => values.push(value));
return values;
}
private toKey(resource: URI): string {
let key: string;
......
......@@ -339,6 +339,16 @@ suite('Map', () => {
map.set(resource2, '2');
map.set(resource3, true);
const values = map.values();
assert.equal(values[0], 1);
assert.equal(values[1], '2');
assert.equal(values[2], true);
let counter = 0;
map.forEach(value => {
assert.equal(value, values[counter++]);
});
const obj = Object.create(null);
map.set(resource4, obj);
......@@ -384,6 +394,12 @@ suite('Map', () => {
assert.ok(!map.get(resource2));
assert.ok(!map.get(resource3));
assert.ok(!map.has(resource1));
map.set(resource1, false);
map.set(resource2, 0);
assert.ok(map.has(resource1));
assert.ok(map.has(resource2));
});
test('ResourceMap - files', function () {
......
......@@ -12,6 +12,7 @@ import events = require('vs/base/common/events');
import { isLinux } from 'vs/base/common/platform';
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import Event from 'vs/base/common/event';
import { Schemas } from 'vs/base/common/network';
export const IFileService = createDecorator<IFileService>('fileService');
......@@ -290,17 +291,49 @@ export class FileChangesEvent extends events.Event {
}
}
export function isEqual(path1: string, path2: string): boolean {
const identityEquals = (path1 === path2);
export function isEqual(resourceA: URI, resourceB: URI): boolean;
export function isEqual(pathA: string, pathB: string): boolean;
export function isEqual(resourceOrPathA: string | URI, resourceOrPathB: string | URI): boolean {
const identityEquals = (resourceOrPathA === resourceOrPathB);
if (identityEquals) {
return true;
}
if (!resourceOrPathA || !resourceOrPathB) {
return false;
}
// Compare by URI
if (typeof resourceOrPathA !== 'string') {
const resourceA = resourceOrPathA;
const resourceB = resourceOrPathB as URI;
if (resourceA.scheme !== resourceB.scheme) {
return false;
}
// File URIs compare by fsPath
if (resourceA.scheme === Schemas.file) {
return isEqual(resourceA.fsPath, resourceB.fsPath);
}
// Non-file URIs compare by full string
return resourceA.toString() === resourceB.toString();
}
// Compare by Path
const pathA = resourceOrPathA;
const pathB = resourceOrPathB as string;
if (isLinux || identityEquals) {
return identityEquals;
}
if (path1.length !== path2.length) {
if (pathA.length !== pathB.length) {
return false;
}
return path1.toLowerCase() === path2.toLowerCase();
return pathA.toLowerCase() === pathB.toLowerCase();
}
export function isParent(path: string, candidate: string): boolean {
......
......@@ -49,16 +49,24 @@ suite('Files', () => {
test('isEqual', function () {
assert.ok(isEqual('/some/path', '/some/path'));
assert.ok(isEqual(URI.file('/some/path'), URI.file('/some/path')));
assert.ok(isEqual('c:\\some\\path', 'c:\\some\\path'));
assert.ok(isEqual(URI.file('c:\\some\\path'), URI.file('c:\\some\\path')));
assert.ok(!isEqual('/some/path', '/some/other/path'));
assert.ok(!isEqual(URI.file('/some/path'), URI.file('/some/other/path')));
assert.ok(!isEqual('c:\\some\\path', 'c:\\some\\other\\path'));
assert.ok(!isEqual(URI.file('c:\\some\\path'), URI.file('c:\\some\\other\\path')));
if (isLinux) {
assert.ok(!isEqual('/some/path', '/some/PATH'));
assert.ok(!isEqual(URI.file('/some/path'), URI.file('/some/PATH')));
} else {
assert.ok(isEqual('/some/path', '/some/PATH'));
assert.ok(isEqual('c:\\some\\path', 'c:\\some\\PATH'));
assert.ok(isEqual(URI.file('/some/path'), URI.file('/some/PATH')));
assert.ok(isEqual(URI.file('c:\\some\\path'), URI.file('c:\\some\\PATH')));
}
assert.ok(isEqual(URI.parse('some://cool/uri'), URI.parse('some://cool/uri')));
assert.ok(!isEqual(URI.parse('some://cool/uri'), URI.parse('some://other/uri')));
});
test('isParent', function () {
......
......@@ -34,7 +34,7 @@ import { IEditor as IBaseEditor, IEditorInput } from 'vs/platform/editor/common/
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService, IPickOpenEntry, IFilePickOpenEntry } from 'vs/platform/quickOpen/common/quickOpen';
import { IWorkspaceConfigurationService } from 'vs/workbench/services/configuration/common/configuration';
import { IFilesConfiguration, SUPPORTED_ENCODINGS } from 'vs/platform/files/common/files';
import { IFilesConfiguration, SUPPORTED_ENCODINGS, isEqual } from 'vs/platform/files/common/files';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IModeService } from 'vs/editor/common/services/modeService';
import { IModelService } from 'vs/editor/common/services/modelService';
......@@ -649,7 +649,7 @@ export class EditorStatus implements IStatusbarItem {
const activeEditor = this.editorService.getActiveEditor();
if (activeEditor) {
const activeResource = toResource(activeEditor.input, { supportSideBySide: true, filter: ['file', 'untitled'] });
if (activeResource && activeResource.toString() === resource.toString()) {
if (isEqual(activeResource, resource)) {
return this.onEncodingChange(<IBaseEditor>activeEditor); // only update if the encoding changed for the active resource
}
}
......
......@@ -15,7 +15,6 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { Registry } from 'vs/platform/platform';
import { Position, Direction } from 'vs/platform/editor/common/editor';
import { Schemas } from 'vs/base/common/network';
import { isEqual } from 'vs/platform/files/common/files';
import { ResourceMap } from 'vs/base/common/map';
......@@ -200,10 +199,8 @@ export class EditorGroup implements IEditorGroup {
for (let i = 0; i < this.editors.length; i++) {
const editor = this.editors[i];
const editorResource = toResource(editor, { supportSideBySide: true });
if (editorResource && editorResource.scheme === resource.scheme) {
if (resource.scheme === Schemas.file && isEqual(editorResource.fsPath, resource.fsPath) || (resource.scheme !== Schemas.file && editorResource.toString() === resource.toString())) {
return editor;
}
if (isEqual(editorResource, resource)) {
return editor;
}
}
......
......@@ -28,6 +28,7 @@ import { CommandsRegistry, ICommandHandler } from 'vs/platform/commands/common/c
import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
import { explorerItemToFileResource, ExplorerFocusCondition, FilesExplorerFocusCondition } from 'vs/workbench/parts/files/common/files';
import { isEqual } from 'vs/platform/files/common/files';
class FilesViewerActionContributor extends ActionBarContributor {
......@@ -90,7 +91,7 @@ class FilesViewerActionContributor extends ActionBarContributor {
}
const workspace = this.contextService.getWorkspace();
const isRoot = workspace && stat.resource.toString() === workspace.resource.toString();
const isRoot = workspace && isEqual(stat.resource.fsPath, workspace.resource.fsPath);
// Copy File/Folder
if (!isRoot) {
......
......@@ -996,7 +996,7 @@ export class PasteFileAction extends BaseFileAction {
}
// Check if target is ancestor of pasted folder
if (this.element.resource.toString() !== fileToCopy.resource.toString() && (isEqual(this.element.resource.fsPath, fileToCopy.resource.fsPath) || isParent(this.element.resource.fsPath, fileToCopy.resource.fsPath))) {
if (!isEqual(this.element.resource.fsPath, fileToCopy.resource.fsPath) && (isEqual(this.element.resource.fsPath, fileToCopy.resource.fsPath) || isParent(this.element.resource.fsPath, fileToCopy.resource.fsPath))) {
return false;
}
......@@ -1007,7 +1007,7 @@ export class PasteFileAction extends BaseFileAction {
// Find target
let target: FileStat;
if (this.element.resource.toString() === fileToCopy.resource.toString()) {
if (isEqual(this.element.resource.fsPath, fileToCopy.resource.fsPath)) {
target = this.element.parent;
} else {
target = this.element.isDirectory ? this.element : this.element.parent;
......@@ -1313,7 +1313,7 @@ export class CompareResourcesAction extends Action {
}
// Check if target is identical to source
if (this.resource.toString() === globalResourceToCompare.toString()) {
if (isEqual(this.resource.fsPath, globalResourceToCompare.fsPath)) {
return false;
}
......@@ -1408,7 +1408,7 @@ export abstract class BaseSaveFileAction extends BaseActionWithErrorReporting {
const editor = getCodeEditor(activeEditor);
if (editor) {
const activeResource = toResource(activeEditor.input, { supportSideBySide: true, filter: ['file', 'untitled'] });
if (activeResource && activeResource.toString() === source.toString()) {
if (activeResource && isEqual(activeResource.fsPath, source.fsPath)) {
viewStateOfSource = editor.saveViewState();
}
}
......
......@@ -27,12 +27,13 @@ import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textF
import { ITextModelResolverService, ITextModelContentProvider } from 'vs/editor/common/services/resolverService';
import { IModel } from 'vs/editor/common/editorCommon';
import { toResource } from 'vs/workbench/common/editor';
import { ResourceMap } from 'vs/base/common/map';
export const CONFLICT_RESOLUTION_SCHEME = 'conflictResolution';
// A handler for save error happening with conflict resolution actions
export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContribution, ITextModelContentProvider {
private messages: { [resource: string]: () => void };
private messages: ResourceMap<() => void>;
private toUnbind: IDisposable[];
constructor(
......@@ -43,7 +44,7 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
@IModeService private modeService: IModeService,
@IInstantiationService private instantiationService: IInstantiationService
) {
this.messages = Object.create(null);
this.messages = new ResourceMap<() => void>();
this.toUnbind = [];
// Register as text model content provider that supports to load a resource as it actually
......@@ -82,10 +83,10 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
}
private onFileSavedOrReverted(resource: URI): void {
const hideMessage = this.messages[resource.toString()];
const hideMessage = this.messages.get(resource);
if (hideMessage) {
hideMessage();
this.messages[resource.toString()] = void 0;
this.messages.delete(resource);
}
}
......@@ -157,11 +158,13 @@ export class SaveErrorHandler implements ISaveErrorHandler, IWorkbenchContributi
}
// Show message and keep function to hide in case the file gets saved/reverted
this.messages[model.getResource().toString()] = this.messageService.show(Severity.Error, message);
this.messages.set(model.getResource(), this.messageService.show(Severity.Error, message));
}
public dispose(): void {
this.toUnbind = dispose(this.toUnbind);
this.messages.clear();
}
}
......
......@@ -112,7 +112,8 @@ export class FileDataSource implements IDataSource {
}
// Return if root reached
if (this.contextService.hasWorkspace() && stat.resource.toString() === this.contextService.getWorkspace().resource.toString()) {
const workspace = this.contextService.getWorkspace();
if (workspace && isEqual(stat.resource.fsPath, workspace.resource.fsPath)) {
return TPromise.as(null);
}
......@@ -411,7 +412,8 @@ export class FileController extends DefaultController {
}
// Handle root
if (this.contextService.getWorkspace() && stat.resource.toString() === this.contextService.getWorkspace().resource.toString()) {
const workspace = this.contextService.getWorkspace();
if (workspace && isEqual(stat.resource.fsPath, workspace.resource.fsPath)) {
tree.clearFocus(payload);
tree.clearSelection(payload);
......@@ -687,7 +689,7 @@ export class FileDragAndDrop implements IDragAndDrop {
return true; // NewStatPlaceholders can not be moved
}
if (source.resource.toString() === target.resource.toString()) {
if (isEqual(source.resource.fsPath, target.resource.fsPath)) {
return true; // Can not move anything onto itself
}
......@@ -710,7 +712,8 @@ export class FileDragAndDrop implements IDragAndDrop {
return fromDesktop || isCopy ? DRAG_OVER_ACCEPT_BUBBLE_DOWN_COPY(true) : DRAG_OVER_ACCEPT_BUBBLE_DOWN(true);
}
if (target.resource.toString() !== this.contextService.getWorkspace().resource.toString()) {
const workspace = this.contextService.getWorkspace();
if (workspace && !isEqual(target.resource.fsPath, workspace.resource.fsPath)) {
return fromDesktop || isCopy ? DRAG_OVER_ACCEPT_BUBBLE_UP_COPY : DRAG_OVER_ACCEPT_BUBBLE_UP;
}
......
......@@ -12,6 +12,7 @@ import { IFileStat, isEqual, isParent } from 'vs/platform/files/common/files';
import { UntitledEditorInput } from 'vs/workbench/common/editor/untitledEditorInput';
import { IEditorInput } from 'vs/platform/editor/common/editor';
import { IEditorGroup, toResource } from 'vs/workbench/common/editor';
import { ResourceMap } from 'vs/base/common/map';
export enum StatType {
FILE,
......@@ -104,9 +105,9 @@ export class FileStat implements IFileStat {
if (mergingDirectories && disk.isDirectoryResolved) {
// Map resource => stat
const oldLocalChildren: { [resource: string]: FileStat; } = Object.create(null);
const oldLocalChildren = new ResourceMap<FileStat>();
local.children.forEach((localChild: FileStat) => {
oldLocalChildren[localChild.resource.toString()] = localChild;
oldLocalChildren.set(localChild.resource, localChild);
});
// Clear current children
......@@ -114,7 +115,7 @@ export class FileStat implements IFileStat {
// Merge received children
disk.children.forEach((diskChild: FileStat) => {
const formerLocalChild = oldLocalChildren[diskChild.resource.toString()];
const formerLocalChild = oldLocalChildren.get(diskChild.resource);
// Existing child: merge
if (formerLocalChild) {
......@@ -177,7 +178,7 @@ export class FileStat implements IFileStat {
*/
public removeChild(child: FileStat): void {
for (let i = 0; i < this.children.length; i++) {
if (this.children[i].resource.toString() === child.resource.toString()) {
if (isEqual(this.children[i].resource.fsPath, child.resource.fsPath)) {
this.children.splice(i, 1);
break;
}
......@@ -291,7 +292,7 @@ export class NewStatPlaceholder extends FileStat {
}
public getId(): string {
return 'new-stat-placeholder:' + this.id + ':' + this.parent.resource.toString();
return `new-stat-placeholder:${this.id}:${this.parent.resource.toString()}`;
}
public isDirectoryPlaceholder(): boolean {
......
......@@ -36,6 +36,7 @@ import { ContributableActionProvider } from 'vs/workbench/browser/actionBarRegis
import { IContextKeyService, IContextKey } from 'vs/platform/contextkey/common/contextkey';
import { IListService } from 'vs/platform/list/browser/listService';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { isEqual } from 'vs/platform/files/common/files';
export class MarkersPanel extends Panel {
......@@ -246,7 +247,7 @@ export class MarkersPanel extends Panel {
if (resourceForCurrentActiveFile) {
return false;
}
return changedResources.some(r => r.toString() === this.currentActiveFile.toString());
return changedResources.some(r => isEqual(r, this.currentActiveFile));
}
private onEditorsChanged(): void {
......@@ -333,7 +334,7 @@ export class MarkersPanel extends Panel {
private getResourceForCurrentActiveFile(): Resource {
if (this.currentActiveFile) {
let resources = this.markersModel.filteredResources.filter((resource): boolean => {
return this.currentActiveFile.toString() === resource.uri.toString();
return isEqual(this.currentActiveFile, resource.uri);
});
return resources.length > 0 ? resources[0] : null;
}
......@@ -344,7 +345,7 @@ export class MarkersPanel extends Panel {
let selectedElement = this.tree.getSelection();
if (selectedElement && selectedElement.length > 0) {
if (selectedElement[0] instanceof Marker) {
if (resource.uri.toString() === selectedElement[0].marker.resource.toString()) {
if (isEqual(resource.uri, selectedElement[0].marker.resource)) {
return true;
}
}
......
......@@ -23,7 +23,7 @@ import { ITextModelResolverService, ITextModelContentProvider } from 'vs/editor/
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
import { IModel } from 'vs/editor/common/editorCommon';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IFileService } from 'vs/platform/files/common/files';
import { IFileService, isEqual } from 'vs/platform/files/common/files';
const REPLACE_PREVIEW = 'replacePreview';
......@@ -69,7 +69,7 @@ class ReplacePreviewModel extends Disposable {
resolve(replacePreviewUri: URI): TPromise<IModel> {
const fileResource = toFileResource(replacePreviewUri);
const fileMatch = <FileMatch>this.searchWorkbenchService.searchModel.searchResult.matches().filter(match => match.resource().toString() === fileResource.toString())[0];
const fileMatch = <FileMatch>this.searchWorkbenchService.searchModel.searchResult.matches().filter(match => isEqual(match.resource(), fileResource))[0];
return this.textModelResolverService.createModelReference(fileResource).then(ref => {
ref = this._register(ref);
const sourceModel = ref.object.textEditorModel;
......
......@@ -30,7 +30,7 @@ import { Scope } from 'vs/workbench/common/memento';
import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences';
import { IEditorGroupService } from 'vs/workbench/services/group/common/groupService';
import { getOutOfWorkspaceEditorResources } from 'vs/workbench/common/editor';
import { FileChangeType, FileChangesEvent, IFileService } from 'vs/platform/files/common/files';
import { FileChangeType, FileChangesEvent, IFileService, isEqual } from 'vs/platform/files/common/files';
import { Viewlet } from 'vs/workbench/browser/viewlet';
import { Match, FileMatch, SearchModel, FileMatchOrMatch, IChangeEvent, ISearchWorkbenchService } from 'vs/workbench/parts/search/common/searchModel';
import { QueryBuilder } from 'vs/workbench/parts/search/common/searchQuery';
......@@ -892,7 +892,7 @@ export class SearchViewlet extends Viewlet {
return;
}
if (workspace.resource.toString() === resource.toString()) {
if (isEqual(workspace.resource.fsPath, resource.fsPath)) {
this.inputPatternIncludes.setValue('');
this.searchWidget.focus();
return;
......
......@@ -24,6 +24,7 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import { IReplaceService } from 'vs/workbench/parts/search/common/replace';
import { IProgressRunner } from 'vs/platform/progress/common/progress';
import { RangeHighlightDecorations } from 'vs/workbench/common/editor/rangeDecorations';
import { isEqual } from 'vs/platform/files/common/files';
export class Match {
......@@ -149,7 +150,7 @@ export class FileMatch extends Disposable {
private registerListeners(): void {
this._register(this.modelService.onModelAdded((model: IModel) => {
if (model.uri.toString() === this._resource.toString()) {
if (isEqual(model.uri, this._resource)) {
this.bindModel(model);
}
}));
......
......@@ -20,6 +20,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IRawSearch, ISerializedSearchComplete, ISerializedSearchProgressItem, ISerializedFileMatch, IRawSearchService } from './search';
import { ISearchChannel, SearchChannelClient } from './searchIpc';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ResourceMap } from 'vs/base/common/map';
export class SearchService implements ISearchService {
public _serviceBrand: any;
......@@ -69,7 +70,7 @@ export class SearchService implements ISearchService {
let flushLocalResultsOnce = function () {
if (!localResultsFlushed) {
localResultsFlushed = true;
Object.keys(localResults).map((key) => localResults[key]).filter((res) => !!res).forEach(onProgress);
localResults.values().filter((res) => !!res).forEach(onProgress);
}
};
......@@ -81,7 +82,7 @@ export class SearchService implements ISearchService {
flushLocalResultsOnce();
onComplete({
limitHit: complete.limitHit,
results: complete.results.filter((match) => typeof localResults[match.resource.toString()] === 'undefined'), // dont override local results
results: complete.results.filter((match) => !localResults.has(match.resource)), // dont override local results
stats: complete.stats
});
},
......@@ -98,7 +99,7 @@ export class SearchService implements ISearchService {
// Match
if (progress.resource) {
if (typeof localResults[progress.resource.toString()] === 'undefined') { // don't override local results
if (!localResults.has(progress.resource)) { // don't override local results
onProgress(progress);
}
}
......@@ -111,8 +112,8 @@ export class SearchService implements ISearchService {
}, () => rawSearchQuery && rawSearchQuery.cancel());
}
private getLocalResults(query: ISearchQuery): { [resourcePath: string]: IFileMatch; } {
let localResults: { [resourcePath: string]: IFileMatch; } = Object.create(null);
private getLocalResults(query: ISearchQuery): ResourceMap<IFileMatch> {
const localResults = new ResourceMap<IFileMatch>();
if (query.type === QueryType.Text) {
let models = this.modelService.getModels();
......@@ -142,13 +143,13 @@ export class SearchService implements ISearchService {
let matches = model.findMatches(query.contentPattern.pattern, false, query.contentPattern.isRegExp, query.contentPattern.isCaseSensitive, query.contentPattern.isWordMatch, false);
if (matches.length) {
let fileMatch = new FileMatch(resource);
localResults[resource.toString()] = fileMatch;
localResults.set(resource, fileMatch);
matches.forEach((match) => {
fileMatch.lineMatches.push(new LineMatch(model.getLineContent(match.range.startLineNumber), match.range.startLineNumber - 1, [[match.range.startColumn - 1, match.range.endColumn - match.range.startColumn]]));
});
} else {
localResults[resource.toString()] = false; // flag as empty result
localResults.set(resource, false);
}
});
}
......
......@@ -29,6 +29,7 @@ import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorMo
import { TextFileEditorModelManager } from 'vs/workbench/services/textfile/common/textFileEditorModelManager';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IMessageService, Severity } from 'vs/platform/message/common/message';
import { ResourceMap } from 'vs/base/common/map';
export interface IBackupResult {
didBackup: boolean;
......@@ -486,22 +487,22 @@ export abstract class TextFileService implements ITextFileService {
return true;
});
const mapResourceToResult: { [resource: string]: IResult } = Object.create(null);
const mapResourceToResult = new ResourceMap<IResult>();
dirtyFileModels.forEach(m => {
mapResourceToResult[m.getResource().toString()] = {
mapResourceToResult.set(m.getResource(), {
source: m.getResource()
};
});
});
return TPromise.join(dirtyFileModels.map(model => {
return model.save({ reason }).then(() => {
if (!model.isDirty()) {
mapResourceToResult[model.getResource().toString()].success = true;
mapResourceToResult.get(model.getResource()).success = true;
}
});
})).then(r => {
return {
results: Object.keys(mapResourceToResult).map(k => mapResourceToResult[k])
results: mapResourceToResult.values()
};
});
}
......@@ -652,34 +653,35 @@ export abstract class TextFileService implements ITextFileService {
private doRevertAllFiles(resources?: URI[], options?: IRevertOptions): TPromise<ITextFileOperationResult> {
const fileModels = options && options.force ? this.getFileModels(resources) : this.getDirtyFileModels(resources);
const mapResourceToResult: { [resource: string]: IResult } = Object.create(null);
const mapResourceToResult = new ResourceMap<IResult>();
fileModels.forEach(m => {
mapResourceToResult[m.getResource().toString()] = {
mapResourceToResult.set(m.getResource(), {
source: m.getResource()
};
});
});
return TPromise.join(fileModels.map(model => {
return model.revert(options && options.soft).then(() => {
if (!model.isDirty()) {
mapResourceToResult[model.getResource().toString()].success = true;
mapResourceToResult.get(model.getResource()).success = true;
}
}, error => {
// FileNotFound means the file got deleted meanwhile, so still record as successful revert
if ((<IFileOperationResult>error).fileOperationResult === FileOperationResult.FILE_NOT_FOUND) {
mapResourceToResult[model.getResource().toString()].success = true;
mapResourceToResult.get(model.getResource()).success = true;
}
// Otherwise bubble up the error
else {
return TPromise.wrapError(error);
}
return undefined;
});
})).then(r => {
return {
results: Object.keys(mapResourceToResult).map(k => mapResourceToResult[k])
results: mapResourceToResult.values()
};
});
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册