Refresh master with initial release/0.24 snapshot (#332)

* Initial port of release/0.24 source code

* Fix additional headers

* Fix a typo in launch.json
This commit is contained in:
Karl Burtram
2017-12-15 15:38:57 -08:00
committed by GitHub
parent 271b3a0b82
commit 6ad0df0e3e
7118 changed files with 107999 additions and 56466 deletions

View File

@@ -17,7 +17,7 @@ import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { IRevertOptions, IResult, ITextFileOperationResult, ITextFileService, IRawTextContent, IAutoSaveConfiguration, AutoSaveMode, SaveReason, ITextFileEditorModelManager, ITextFileEditorModel, ModelState, ISaveOptions } from 'vs/workbench/services/textfile/common/textfiles';
import { ConfirmResult } from 'vs/workbench/common/editor';
import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
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';
@@ -85,8 +85,15 @@ export abstract class TextFileService implements ITextFileService {
const configuration = this.configurationService.getConfiguration<IFilesConfiguration>();
this.currentFilesAssociationConfig = configuration && configuration.files && configuration.files.associations;
this.onConfigurationChange(configuration);
this.onFilesConfigurationChange(configuration);
/* __GDPR__
"autoSave" : {
"${include}": [
"${IAutoSaveConfiguration}"
]
}
*/
this.telemetryService.publicLog('autoSave', this.getAutoSaveConfiguration());
this.registerListeners();
@@ -116,8 +123,12 @@ export abstract class TextFileService implements ITextFileService {
this.lifecycleService.onWillShutdown(event => event.veto(this.beforeShutdown(event.reason)));
this.lifecycleService.onShutdown(this.dispose, this);
// Configuration changes
this.toUnbind.push(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationChange(this.configurationService.getConfiguration<IFilesConfiguration>())));
// Files configuration changes
this.toUnbind.push(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('files')) {
this.onFilesConfigurationChange(this.configurationService.getConfiguration<IFilesConfiguration>());
}
}));
}
private beforeShutdown(reason: ShutdownReason): boolean | TPromise<boolean> {
@@ -180,7 +191,7 @@ export abstract class TextFileService implements ITextFileService {
let doBackup: boolean;
switch (reason) {
case ShutdownReason.CLOSE:
if (this.contextService.hasWorkspace() && this.configuredHotExit === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.configuredHotExit === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
doBackup = true; // backup if a folder is open and onExitAndWindowClose is configured
} else if (windowCount > 1 || platform.isMacintosh) {
doBackup = false; // do not backup if a window is closed that does not cause quitting of the application
@@ -198,7 +209,7 @@ export abstract class TextFileService implements ITextFileService {
break;
case ShutdownReason.LOAD:
if (this.contextService.hasWorkspace() && this.configuredHotExit === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.configuredHotExit === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
doBackup = true; // backup if a folder is open and onExitAndWindowClose is configured
} else {
doBackup = false; // do not backup because we are switching contexts
@@ -211,6 +222,13 @@ export abstract class TextFileService implements ITextFileService {
}
// 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
@@ -302,7 +320,7 @@ export abstract class TextFileService implements ITextFileService {
return this.backupFileService.discardAllWorkspaceBackups();
}
protected onConfigurationChange(configuration: IFilesConfiguration): void {
protected onFilesConfigurationChange(configuration: IFilesConfiguration): void {
const wasAutoSaveEnabled = (this.getAutoSaveMode() !== AutoSaveMode.OFF);
const autoSaveMode = (configuration && configuration.files && configuration.files.autoSave) || AutoSaveConfiguration.OFF;
@@ -347,10 +365,8 @@ export abstract class TextFileService implements ITextFileService {
this._onFilesAssociationChange.fire();
}
// {{SQL CARBON EDIT}}
// Hot exit
//const hotExitMode = configuration && configuration.files ? configuration.files.hotExit : HotExitConfiguration.ON_EXIT;
const hotExitMode = HotExitConfiguration.OFF;
const hotExitMode = configuration && configuration.files ? configuration.files.hotExit : HotExitConfiguration.ON_EXIT;
if (hotExitMode === HotExitConfiguration.OFF || hotExitMode === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
this.configuredHotExit = hotExitMode;
} else {
@@ -409,10 +425,14 @@ export abstract class TextFileService implements ITextFileService {
const filesToSave: URI[] = [];
const untitledToSave: URI[] = [];
toSave.forEach(s => {
if (s.scheme === Schemas.file) {
filesToSave.push(s);
} else if ((Array.isArray(arg1) || arg1 === true /* includeUntitled */) && s.scheme === UNTITLED_SCHEMA) {
// TODO@remote
// if (s.scheme === Schemas.file) {
// filesToSave.push(s);
// } else
if ((Array.isArray(arg1) || arg1 === true /* includeUntitled */) && s.scheme === UNTITLED_SCHEMA) {
untitledToSave.push(s);
} else {
filesToSave.push(s);
}
});
@@ -619,12 +639,14 @@ export abstract class TextFileService implements ITextFileService {
}
private suggestFileName(untitledResource: URI): string {
const root = this.historyService.getLastActiveWorkspaceRoot();
if (root) {
return URI.file(paths.join(root.fsPath, this.untitledEditorService.suggestFileName(untitledResource))).fsPath;
const untitledFileName = this.untitledEditorService.suggestFileName(untitledResource);
const lastActiveFile = this.historyService.getLastActiveFile();
if (lastActiveFile) {
return URI.file(paths.join(paths.dirname(lastActiveFile.fsPath), untitledFileName)).fsPath;
}
return this.untitledEditorService.suggestFileName(untitledResource);
return untitledFileName;
}
public revert(resource: URI, options?: IRevertOptions): TPromise<boolean> {
@@ -714,4 +736,4 @@ export abstract class TextFileService implements ITextFileService {
// Clear all caches
this._models.clear();
}
}
}