Merge VS Code 1.21 source code (#1067)

* Initial VS Code 1.21 file copy with patches

* A few more merges

* Post npm install

* Fix batch of build breaks

* Fix more build breaks

* Fix more build errors

* Fix more build breaks

* Runtime fixes 1

* Get connection dialog working with some todos

* Fix a few packaging issues

* Copy several node_modules to package build to fix loader issues

* Fix breaks from master

* A few more fixes

* Make tests pass

* First pass of license header updates

* Second pass of license header updates

* Fix restore dialog issues

* Remove add additional themes menu items

* fix select box issues where the list doesn't show up

* formatting

* Fix editor dispose issue

* Copy over node modules to correct location on all platforms
This commit is contained in:
Karl Burtram
2018-04-04 15:27:51 -07:00
committed by GitHub
parent 5fba3e31b4
commit dafb780987
9412 changed files with 141255 additions and 98813 deletions

View File

@@ -10,7 +10,7 @@ import errors = require('vs/base/common/errors');
import URI from 'vs/base/common/uri';
import { IEditor } from 'vs/editor/common/editorCommon';
import { IEditor as IBaseEditor, IEditorInput, ITextEditorOptions, IResourceInput, ITextEditorSelection, Position as GroupPosition } from 'vs/platform/editor/common/editor';
import { Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorGroup, IEditorInputFactoryRegistry, toResource } from 'vs/workbench/common/editor';
import { Extensions as EditorExtensions, EditorInput, IEditorCloseEvent, IEditorGroup, IEditorInputFactoryRegistry, toResource, Extensions as EditorInputExtensions, IFileInputFactory } from 'vs/workbench/common/editor';
import { IWorkbenchEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IHistoryService } from 'vs/workbench/services/history/common/history';
import { FileChangesEvent, IFileService, FileChangeType, FILES_EXCLUDE_CONFIG } from 'vs/platform/files/common/files';
@@ -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.
@@ -89,22 +90,87 @@ interface IEditorIdentifier {
position: GroupPosition;
}
export abstract class BaseHistoryService {
interface IStackEntry {
input: IEditorInput | IResourceInput;
selection?: ITextEditorSelection;
timestamp: number;
}
protected toUnbind: IDisposable[];
interface IRecentlyClosedFile {
resource: URI;
index: number;
}
export class HistoryService implements IHistoryService {
public _serviceBrand: any;
private static readonly STORAGE_KEY = 'history.entries';
private static readonly MAX_HISTORY_ITEMS = 200;
private static readonly MAX_STACK_ITEMS = 20;
private static readonly MAX_RECENTLY_CLOSED_EDITORS = 20;
private toUnbind: IDisposable[];
private activeEditorListeners: IDisposable[];
private lastActiveEditor: IEditorIdentifier;
private stack: IStackEntry[];
private index: number;
private lastIndex: number;
private navigatingInStack: boolean;
private currentTextEditorState: TextEditorState;
private history: (IEditorInput | IResourceInput)[];
private recentlyClosedFiles: IRecentlyClosedFile[];
private loaded: boolean;
private resourceFilter: ResourceGlobMatcher;
private fileInputFactory: IFileInputFactory;
constructor(
protected editorGroupService: IEditorGroupService,
protected editorService: IWorkbenchEditorService
@IWorkbenchEditorService private editorService: IWorkbenchEditorService,
@IEditorGroupService private editorGroupService: IEditorGroupService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IStorageService private storageService: IStorageService,
@IConfigurationService private configurationService: IConfigurationService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IFileService private fileService: IFileService,
@IWindowsService private windowService: IWindowsService,
@IInstantiationService private instantiationService: IInstantiationService,
) {
this.toUnbind = [];
this.activeEditorListeners = [];
// Listeners
this.fileInputFactory = Registry.as<IEditorInputFactoryRegistry>(EditorInputExtensions.EditorInputFactories).getFileInputFactory();
this.index = -1;
this.lastIndex = -1;
this.stack = [];
this.recentlyClosedFiles = [];
this.loaded = false;
this.resourceFilter = instantiationService.createInstance(
ResourceGlobMatcher,
(root: URI) => this.getExcludes(root),
(event: IConfigurationChangeEvent) => event.affectsConfiguration(FILES_EXCLUDE_CONFIG) || event.affectsConfiguration('search.exclude')
);
this.registerListeners();
}
private getExcludes(root?: URI): IExpression {
const scope = root ? { resource: root } : void 0;
return getExcludes(this.configurationService.getValue<ISearchConfiguration>(scope));
}
private registerListeners(): void {
this.toUnbind.push(this.editorGroupService.onEditorsChanged(() => this.onEditorsChanged()));
this.toUnbind.push(this.lifecycleService.onShutdown(reason => this.saveHistory()));
this.toUnbind.push(this.editorGroupService.onEditorOpenFail(editor => this.remove(editor)));
this.toUnbind.push(this.editorGroupService.getStacksModel().onEditorClosed(event => this.onEditorClosed(event)));
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this.toUnbind.push(this.resourceFilter.onExpressionChange(() => this.handleExcludesChange()));
}
private onEditorsChanged(): void {
@@ -148,94 +214,6 @@ export abstract class BaseHistoryService {
return identifier.editor.matches(editor.input);
}
protected abstract handleExcludesChange(): void;
protected abstract handleEditorSelectionChangeEvent(editor?: IBaseEditor, event?: ICursorPositionChangedEvent): void;
protected abstract handleActiveEditorChange(editor?: IBaseEditor): void;
public dispose(): void {
this.toUnbind = dispose(this.toUnbind);
}
}
interface IStackEntry {
input: IEditorInput | IResourceInput;
selection?: ITextEditorSelection;
timestamp: number;
}
interface IRecentlyClosedFile {
resource: URI;
index: number;
}
export class HistoryService extends BaseHistoryService implements IHistoryService {
public _serviceBrand: any;
private static readonly STORAGE_KEY = 'history.entries';
private static readonly MAX_HISTORY_ITEMS = 200;
private static readonly MAX_STACK_ITEMS = 20;
private static readonly MAX_RECENTLY_CLOSED_EDITORS = 20;
private stack: IStackEntry[];
private index: number;
private lastIndex: number;
private navigatingInStack: boolean;
private currentTextEditorState: TextEditorState;
private history: (IEditorInput | IResourceInput)[];
private recentlyClosedFiles: IRecentlyClosedFile[];
private loaded: boolean;
private resourceFilter: ResourceGlobMatcher;
constructor(
@IWorkbenchEditorService editorService: IWorkbenchEditorService,
@IEditorGroupService editorGroupService: IEditorGroupService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IStorageService private storageService: IStorageService,
@IConfigurationService private configurationService: IConfigurationService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IFileService private fileService: IFileService,
@IWindowsService private windowService: IWindowsService,
@IInstantiationService private instantiationService: IInstantiationService,
) {
super(editorGroupService, editorService);
this.index = -1;
this.lastIndex = -1;
this.stack = [];
this.recentlyClosedFiles = [];
this.loaded = false;
this.resourceFilter = instantiationService.createInstance(
ResourceGlobMatcher,
(root: URI) => this.getExcludes(root),
(event: IConfigurationChangeEvent) => event.affectsConfiguration(FILES_EXCLUDE_CONFIG) || event.affectsConfiguration('search.exclude')
);
this.registerListeners();
}
private setIndex(value: number): void {
this.lastIndex = this.index;
this.index = value;
}
private getExcludes(root?: URI): IExpression {
const scope = root ? { resource: root } : void 0;
return getExcludes(this.configurationService.getValue<ISearchConfiguration>(scope));
}
private registerListeners(): void {
this.toUnbind.push(this.lifecycleService.onShutdown(reason => this.saveHistory()));
this.toUnbind.push(this.editorGroupService.onEditorOpenFail(editor => this.remove(editor)));
this.toUnbind.push(this.editorGroupService.getStacksModel().onEditorClosed(event => this.onEditorClosed(event)));
this.toUnbind.push(this.fileService.onFileChanges(e => this.onFileChanges(e)));
this.toUnbind.push(this.resourceFilter.onExpressionChange(() => this.handleExcludesChange()));
}
private onFileChanges(e: FileChangesEvent): void {
if (e.gotDeleted()) {
this.remove(e); // remove from history files that got deleted or moved
@@ -292,6 +270,11 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
this.navigate();
}
private setIndex(value: number): void {
this.lastIndex = this.index;
this.index = value;
}
private doForwardAcrossEditors(): void {
let currentIndex = this.index;
const currentEntry = this.stack[this.index];
@@ -594,10 +577,8 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
}
private preferResourceInput(input: IEditorInput): IEditorInput | IResourceInput {
const resource = input ? input.getResource() : void 0;
const preferResourceInput = resource && this.fileService.canHandleResource(resource); // file'ish things prefer resources
if (preferResourceInput) {
return { resource };
if (this.fileInputFactory.isFileInput(input)) {
return { resource: input.getResource() };
}
return input;
@@ -742,7 +723,7 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
const entriesRaw = this.storageService.get(HistoryService.STORAGE_KEY, StorageScope.WORKSPACE);
if (entriesRaw) {
entries = JSON.parse(entriesRaw).filter(entry => !!entry);
entries = JSON.parse(entriesRaw).filter((entry: object) => !!entry);
}
const registry = Registry.as<IEditorInputFactoryRegistry>(EditorExtensions.EditorInputFactories);
@@ -828,16 +809,20 @@ export class HistoryService extends BaseHistoryService implements IHistoryServic
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;
}
}
return void 0;
}
public dispose(): void {
this.toUnbind = dispose(this.toUnbind);
}
}