Initial VS Code 1.19 source merge (#571)

* Initial 1.19 xcopy

* Fix yarn build

* Fix numerous build breaks

* Next batch of build break fixes

* More build break fixes

* Runtime breaks

* Additional post merge fixes

* Fix windows setup file

* Fix test failures.

* Update license header blocks to refer to source eula
This commit is contained in:
Karl Burtram
2018-01-28 23:37:17 -08:00
committed by GitHub
parent 9a1ac20710
commit 251ae01c3e
8009 changed files with 93378 additions and 35634 deletions

View File

@@ -12,13 +12,11 @@ import { onUnexpectedError } from 'vs/base/common/errors';
import { guessMimeTypes } from 'vs/base/common/mime';
import { toErrorMessage } from 'vs/base/common/errorMessage';
import URI from 'vs/base/common/uri';
// import * as assert from 'vs/base/common/assert';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import paths = require('vs/base/common/paths');
import diagnostics = require('vs/base/common/diagnostics');
import types = require('vs/base/common/types');
import { IMode } from 'vs/editor/common/modes';
import { ILifecycleService, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { ITextFileService, IAutoSaveConfiguration, ModelState, ITextFileEditorModel, ISaveOptions, ISaveErrorHandler, ISaveParticipant, StateChange, SaveReason, IRawTextContent } from 'vs/workbench/services/textfile/common/textfiles';
@@ -40,8 +38,6 @@ import { IHashService } from 'vs/workbench/services/hash/common/hashService';
*/
export class TextFileEditorModel extends BaseTextEditorModel implements ITextFileEditorModel {
public static ID = 'workbench.editors.files.textFileEditorModel';
public static DEFAULT_CONTENT_CHANGE_BUFFER_DELAY = CONTENT_CHANGE_EVENT_BUFFER_DELAY;
public static DEFAULT_ORPHANED_CHANGE_BUFFER_DELAY = 100;
@@ -80,7 +76,6 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
@IModeService modeService: IModeService,
@IModelService modelService: IModelService,
@IFileService private fileService: IFileService,
@ILifecycleService private lifecycleService: ILifecycleService,
@IInstantiationService private instantiationService: IInstantiationService,
@ITelemetryService private telemetryService: ITelemetryService,
@ITextFileService private textFileService: ITextFileService,
@@ -240,7 +235,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
*/
public revert(soft?: boolean): TPromise<void> {
if (!this.isResolved()) {
return TPromise.as<void>(null);
return TPromise.wrap<void>(null);
}
// Cancel any running auto-save
@@ -604,7 +599,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
*/
public save(options: ISaveOptions = Object.create(null)): TPromise<void> {
if (!this.isResolved()) {
return TPromise.as<void>(null);
return TPromise.wrap<void>(null);
}
diag('save() - enter', this.resource, new Date());
@@ -643,7 +638,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
if ((!options.force && !this.dirty) || versionId !== this.versionId) {
diag(`doSave(${versionId}) - exit - because not dirty and/or versionId is different (this.isDirty: ${this.dirty}, this.versionId: ${this.versionId})`, this.resource, new Date());
return TPromise.as<void>(null);
return TPromise.wrap<void>(null);
}
// Return if currently saving by storing this save request as the next save that should happen.
@@ -670,11 +665,9 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
// A save participant can still change the model now and since we are so close to saving
// we do not want to trigger another auto save or similar, so we block this
// In addition we update our version right after in case it changed because of a model change
// We DO NOT run any save participant if we are in the shutdown phase and files are being
// saved as a result of that.
// Save participants can also be skipped through API.
let saveParticipantPromise = TPromise.as(versionId);
if (TextFileEditorModel.saveParticipant && this.lifecycleService.phase !== LifecyclePhase.ShuttingDown && !options.skipSaveParticipants) {
if (TextFileEditorModel.saveParticipant && !options.skipSaveParticipants) {
const onCompleteOrError = () => {
this.blockModelContentChange = false;

View File

@@ -20,7 +20,6 @@ import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
import { IFileService, IResolveContentOptions, IFilesConfiguration, FileOperationError, FileOperationResult, AutoSaveConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
import { IUntitledEditorService, UNTITLED_SCHEMA } from 'vs/workbench/services/untitled/common/untitledEditorService';
@@ -62,7 +61,6 @@ export abstract class TextFileService implements ITextFileService {
private lifecycleService: ILifecycleService,
private contextService: IWorkspaceContextService,
private configurationService: IConfigurationService,
private telemetryService: ITelemetryService,
protected fileService: IFileService,
private untitledEditorService: IUntitledEditorService,
private instantiationService: IInstantiationService,
@@ -82,20 +80,11 @@ export abstract class TextFileService implements ITextFileService {
this._models = this.instantiationService.createInstance(TextFileEditorModelManager);
const configuration = this.configurationService.getConfiguration<IFilesConfiguration>();
const configuration = this.configurationService.getValue<IFilesConfiguration>();
this.currentFilesAssociationConfig = configuration && configuration.files && configuration.files.associations;
this.onFilesConfigurationChange(configuration);
/* __GDPR__
"autoSave" : {
"${include}": [
"${IAutoSaveConfiguration}"
]
}
*/
this.telemetryService.publicLog('autoSave', this.getAutoSaveConfiguration());
this.registerListeners();
}
@@ -105,7 +94,7 @@ export abstract class TextFileService implements ITextFileService {
abstract resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent>;
abstract promptForPath(defaultPath?: string): string;
abstract promptForPath(defaultPath: string): string;
abstract confirmSave(resources?: URI[]): ConfirmResult;
@@ -126,7 +115,7 @@ export abstract class TextFileService implements ITextFileService {
// Files configuration changes
this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('files')) {
this.onFilesConfigurationChange(this.configurationService.getConfiguration<IFilesConfiguration>());
this.onFilesConfigurationChange(this.configurationService.getValue<IFilesConfiguration>());
}
}));
}
@@ -138,9 +127,10 @@ export abstract class TextFileService implements ITextFileService {
if (dirty.length) {
// If auto save is enabled, save all files and then check again for dirty files
// We DO NOT run any save participant if we are in the shutdown phase for performance reasons
let handleAutoSave: TPromise<URI[] /* remaining dirty resources */>;
if (this.getAutoSaveMode() !== AutoSaveMode.OFF) {
handleAutoSave = this.saveAll(false /* files only */).then(() => this.getDirty());
handleAutoSave = this.saveAll(false /* files only */, { skipSaveParticipants: true }).then(() => this.getDirty());
} else {
handleAutoSave = TPromise.as(dirty);
}
@@ -162,7 +152,7 @@ export abstract class TextFileService implements ITextFileService {
return this.confirmBeforeShutdown();
}, errors => {
const firstError = errors[0];
this.messageService.show(Severity.Error, nls.localize('files.backup.failSave', "Files could not be backed up (Error: {0}), try saving your files to exit.", firstError.message));
this.messageService.show(Severity.Error, nls.localize('files.backup.failSave', "Files that are dirty could not be written to the backup location (Error: {0}). Try saving your files first and then exit.", firstError.message));
return true; // veto, the backups failed
});
@@ -221,16 +211,6 @@ export abstract class TextFileService implements ITextFileService {
return TPromise.as({ didBackup: false });
}
// Telemetry
/* __GDPR__
"hotExit:triggered" : {
"reason" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"windowCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"fileCount": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
this.telemetryService.publicLog('hotExit:triggered', { reason, windowCount, fileCount: dirtyToBackup.length });
// Backup
return this.backupAll(dirtyToBackup, textFileEditorModelManager).then(() => { return { didBackup: true }; });
});
@@ -277,7 +257,7 @@ export abstract class TextFileService implements ITextFileService {
// Save
if (confirm === ConfirmResult.SAVE) {
return this.saveAll(true /* includeUntitled */).then(result => {
return this.saveAll(true /* includeUntitled */, { skipSaveParticipants: true }).then(result => {
if (result.results.some(r => !r.success)) {
return true; // veto if some saves failed
}
@@ -366,7 +346,7 @@ export abstract class TextFileService implements ITextFileService {
}
// Hot exit
const hotExitMode = configuration && configuration.files ? configuration.files.hotExit : HotExitConfiguration.ON_EXIT;
const hotExitMode = configuration && configuration.files && configuration.files.hotExit;
if (hotExitMode === HotExitConfiguration.OFF || hotExitMode === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
this.configuredHotExit = hotExitMode;
} else {
@@ -646,6 +626,11 @@ export abstract class TextFileService implements ITextFileService {
return URI.file(paths.join(paths.dirname(lastActiveFile.fsPath), untitledFileName)).fsPath;
}
const lastActiveFolder = this.historyService.getLastActiveWorkspaceRoot('file');
if (lastActiveFolder) {
return URI.file(paths.join(lastActiveFolder.fsPath, untitledFileName)).fsPath;
}
return untitledFileName;
}

View File

@@ -100,13 +100,6 @@ export interface IResult {
success?: boolean;
}
/* __GDPR__FRAGMENT__
"IAutoSaveConfiguration" : {
"autoSaveDelay" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"autoSaveFocusChange": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"autoSaveApplicationChange": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
export interface IAutoSaveConfiguration {
autoSaveDelay: number;
autoSaveFocusChange: boolean;

View File

@@ -18,7 +18,6 @@ import { IUntitledEditorService } from 'vs/workbench/services/untitled/common/un
import { IFileService, IResolveContentOptions } from 'vs/platform/files/common/files';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IModeService } from 'vs/editor/common/services/modeService';
import { ModelBuilder } from 'vs/workbench/services/textfile/electron-browser/modelBuilder';
@@ -33,7 +32,7 @@ import { mnemonicButtonLabel } from 'vs/base/common/labels';
export class TextFileService extends AbstractTextFileService {
private static MAX_CONFIRM_FILES = 10;
private static readonly MAX_CONFIRM_FILES = 10;
constructor(
@IWorkspaceContextService contextService: IWorkspaceContextService,
@@ -41,7 +40,6 @@ export class TextFileService extends AbstractTextFileService {
@IUntitledEditorService untitledEditorService: IUntitledEditorService,
@ILifecycleService lifecycleService: ILifecycleService,
@IInstantiationService instantiationService: IInstantiationService,
@ITelemetryService telemetryService: ITelemetryService,
@IConfigurationService configurationService: IConfigurationService,
@IModeService private modeService: IModeService,
@IWindowService private windowService: IWindowService,
@@ -51,7 +49,7 @@ export class TextFileService extends AbstractTextFileService {
@IWindowsService windowsService: IWindowsService,
@IHistoryService historyService: IHistoryService
) {
super(lifecycleService, contextService, configurationService, telemetryService, fileService, untitledEditorService, instantiationService, messageService, environmentService, backupFileService, windowsService, historyService);
super(lifecycleService, contextService, configurationService, fileService, untitledEditorService, instantiationService, messageService, environmentService, backupFileService, windowsService, historyService);
}
public resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent> {
@@ -132,16 +130,16 @@ export class TextFileService extends AbstractTextFileService {
opts.defaultId = 2;
}
const choice = this.windowService.showMessageBoxSync(opts);
const choice = this.windowService.showMessageBox(opts);
return buttons[choice].result;
}
public promptForPath(defaultPath?: string): string {
public promptForPath(defaultPath: string): string {
return this.windowService.showSaveDialog(this.getSaveDialogOptions(defaultPath));
}
private getSaveDialogOptions(defaultPath?: string): Electron.SaveDialogOptions {
private getSaveDialogOptions(defaultPath: string): Electron.SaveDialogOptions {
const options: Electron.SaveDialogOptions = { defaultPath };
// Filters are only enabled on Windows where they work properly
@@ -189,4 +187,4 @@ export class TextFileService extends AbstractTextFileService {
return options;
}
}
}

View File

@@ -92,7 +92,7 @@ suite('Files - TextFileEditorModel', () => {
const model: TextFileEditorModel = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/index_async.txt'), 'utf8');
model.load().done(() => {
model.textEditorModel.destroy();
model.textEditorModel.dispose();
assert.ok(model.isDisposed());
@@ -447,4 +447,4 @@ suite('Files - TextFileEditorModel', () => {
done();
});
});
});
});

View File

@@ -322,15 +322,15 @@ suite('Files - TextFileEditorModelManager', () => {
const resource = toResource('/path/index_something.txt');
manager.loadOrCreate(resource, { encoding: 'utf8' }).done((model: TextFileEditorModel) => {
manager.loadOrCreate(resource, { encoding: 'utf8' }).done(model => {
model.textEditorModel.setValue('make dirty');
manager.disposeModel(model);
manager.disposeModel(model as TextFileEditorModel);
assert.ok(!model.isDisposed());
model.revert(true);
manager.disposeModel(model);
manager.disposeModel(model as TextFileEditorModel);
assert.ok(model.isDisposed());
manager.dispose();

View File

@@ -373,7 +373,7 @@ suite('Files - TextFileService', () => {
});
});
function hotExitTest(setting: string, shutdownReason: ShutdownReason, multipleWindows: boolean, workspace: true, shouldVeto: boolean, done: () => void): void {
function hotExitTest(this: any, setting: string, shutdownReason: ShutdownReason, multipleWindows: boolean, workspace: true, shouldVeto: boolean, done: () => void): void {
model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/file.txt'), 'utf8');
(<TextFileEditorModelManager>accessor.textFileService.models).add(model.getResource(), model);