mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -05:00
Merge from master
This commit is contained in:
@@ -2,18 +2,15 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as path from 'vs/base/common/paths';
|
||||
import * as nls from 'vs/nls';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import { TPromise, TValueCallback, ErrorCallback } from 'vs/base/common/winjs.base';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { guessMimeTypes } from 'vs/base/common/mime';
|
||||
import { toErrorMessage } from 'vs/base/common/errorMessage';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { IMode } from 'vs/editor/common/modes';
|
||||
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, ILoadOptions, LoadReason } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
@@ -22,10 +19,10 @@ import { BaseTextEditorModel } from 'vs/workbench/common/editor/textEditorModel'
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IFileService, IFileStat, FileOperationError, FileOperationResult, CONTENT_CHANGE_EVENT_BUFFER_DELAY, FileChangesEvent, FileChangeType } from 'vs/platform/files/common/files';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IModeService, ILanguageSelection } from 'vs/editor/common/services/modeService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { RunOnceScheduler, timeout } from 'vs/base/common/async';
|
||||
import { ITextBufferFactory } from 'vs/editor/common/model';
|
||||
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
|
||||
import { createTextBufferFactory } from 'vs/editor/common/model/textModel';
|
||||
@@ -33,7 +30,8 @@ import { INotificationService } from 'vs/platform/notification/common/notificati
|
||||
import { isLinux } from 'vs/base/common/platform';
|
||||
import { IDisposable, toDisposable } from 'vs/base/common/lifecycle';
|
||||
import { ILogService } from 'vs/platform/log/common/log';
|
||||
import { isEqual, isEqualOrParent, hasToIgnoreCase } from 'vs/base/common/resources';
|
||||
import { isEqual, isEqualOrParent } from 'vs/base/common/resources';
|
||||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
|
||||
/**
|
||||
* The text file editor model listens to changes to its underlying code editor model and saves these changes through the file service back to the disk.
|
||||
@@ -153,13 +151,13 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
}
|
||||
|
||||
if (fileEventImpactsModel && this.inOrphanMode !== newInOrphanModeGuess) {
|
||||
let checkOrphanedPromise: TPromise<boolean>;
|
||||
let checkOrphanedPromise: Thenable<boolean>;
|
||||
if (newInOrphanModeGuess) {
|
||||
// We have received reports of users seeing delete events even though the file still
|
||||
// exists (network shares issue: https://github.com/Microsoft/vscode/issues/13665).
|
||||
// Since we do not want to mark the model as orphaned, we have to check if the
|
||||
// file is really gone and not just a faulty file event.
|
||||
checkOrphanedPromise = TPromise.timeout(100).then(() => {
|
||||
checkOrphanedPromise = timeout(100).then(() => {
|
||||
if (this.disposed) {
|
||||
return true;
|
||||
}
|
||||
@@ -167,10 +165,10 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
return this.fileService.existsFile(this.resource).then(exists => !exists);
|
||||
});
|
||||
} else {
|
||||
checkOrphanedPromise = TPromise.as(false);
|
||||
checkOrphanedPromise = Promise.resolve(false);
|
||||
}
|
||||
|
||||
checkOrphanedPromise.done(newInOrphanModeValidated => {
|
||||
checkOrphanedPromise.then(newInOrphanModeValidated => {
|
||||
if (this.inOrphanMode !== newInOrphanModeValidated && !this.disposed) {
|
||||
this.setOrphaned(newInOrphanModeValidated);
|
||||
}
|
||||
@@ -198,9 +196,9 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
}
|
||||
|
||||
const firstLineText = this.getFirstLineText(this.textEditorModel);
|
||||
const mode = this.getOrCreateMode(this.modeService, void 0, firstLineText);
|
||||
const languageSelection = this.getOrCreateMode(this.modeService, void 0, firstLineText);
|
||||
|
||||
this.modelService.setMode(this.textEditorModel, mode);
|
||||
this.modelService.setMode(this.textEditorModel, languageSelection);
|
||||
}
|
||||
|
||||
getVersionId(): number {
|
||||
@@ -357,7 +355,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
if (settingsType) {
|
||||
/* __GDPR__
|
||||
"settingsRead" : {
|
||||
"settingsType": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"settingsType": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('settingsRead', { settingsType }); // Do not log read to user settings.json and .vscode folder as a fileGet event as it ruins our JSON usage data
|
||||
@@ -494,8 +492,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
return this.backupFileService.resolveBackupContent(backup).then(backupContent => backupContent, error => null /* ignore errors */);
|
||||
}
|
||||
|
||||
protected getOrCreateMode(modeService: IModeService, preferredModeIds: string, firstLineText?: string): TPromise<IMode> {
|
||||
return modeService.getOrCreateModeByFilenameOrFirstLine(this.resource.fsPath, firstLineText);
|
||||
protected getOrCreateMode(modeService: IModeService, preferredModeIds: string, firstLineText?: string): ILanguageSelection {
|
||||
return modeService.createByFilepathOrFirstLine(this.resource.fsPath, firstLineText);
|
||||
}
|
||||
|
||||
private onModelContentChanged(): void {
|
||||
@@ -570,7 +568,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
|
||||
// Only trigger save if the version id has not changed meanwhile
|
||||
if (versionId === this.versionId) {
|
||||
this.doSave(versionId, { reason: SaveReason.AUTO }).done(null, onUnexpectedError); // Very important here to not return the promise because if the timeout promise is canceled it will bubble up the error otherwise - do not change
|
||||
this.doSave(versionId, { reason: SaveReason.AUTO }); // Very important here to not return the promise because if the timeout promise is canceled it will bubble up the error otherwise - do not change
|
||||
}
|
||||
}, this.autoSaveAfterMillies);
|
||||
|
||||
@@ -719,7 +717,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
if (settingsType) {
|
||||
/* __GDPR__
|
||||
"settingsWritten" : {
|
||||
"settingsType": { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
|
||||
"settingsType": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryService.publicLog('settingsWritten', { settingsType }); // Do not log write to user settings.json and .vscode folder as a filePUT event as it ruins our JSON usage data
|
||||
@@ -795,7 +793,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
}
|
||||
|
||||
// Check for snippets
|
||||
if (isEqualOrParent(this.resource, URI.file(path.join(this.environmentService.appSettingsHome, 'snippets')), hasToIgnoreCase(this.resource))) {
|
||||
if (isEqualOrParent(this.resource, URI.file(path.join(this.environmentService.appSettingsHome, 'snippets')))) {
|
||||
return 'snippets';
|
||||
}
|
||||
|
||||
@@ -803,7 +801,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
const folders = this.contextService.getWorkspace().folders;
|
||||
for (let i = 0; i < folders.length; i++) {
|
||||
// {{SQL CARBON EDIT}}
|
||||
if (isEqualOrParent(this.resource, folders[i].toResource('.azuredatastudio'), hasToIgnoreCase(this.resource))) {
|
||||
if (isEqualOrParent(this.resource, folders[i].toResource('.azuredatastudio'))) {
|
||||
const filename = path.basename(this.resource.fsPath);
|
||||
if (TextFileEditorModel.WHITELIST_WORKSPACE_JSON.indexOf(filename) > -1) {
|
||||
// {{SQL CARBON EDIT}}
|
||||
@@ -850,7 +848,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
|
||||
// Updated resolved stat with updated stat since touching it might have changed mtime
|
||||
this.updateLastResolvedDiskStat(stat);
|
||||
}, () => void 0 /* gracefully ignore errors if just touching */));
|
||||
}, error => onUnexpectedError(error) /* just log any error but do not notify the user since the file was not dirty */));
|
||||
}
|
||||
|
||||
private setDirty(dirty: boolean): () => void {
|
||||
@@ -963,7 +961,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
}
|
||||
|
||||
if (!this.inConflictMode) {
|
||||
this.save({ overwriteEncoding: true }).done(null, onUnexpectedError);
|
||||
this.save({ overwriteEncoding: true });
|
||||
}
|
||||
}
|
||||
|
||||
@@ -980,7 +978,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
// Load
|
||||
this.load({
|
||||
forceReadFromDisk: true // because encoding has changed
|
||||
}).done(null, onUnexpectedError);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1043,14 +1041,14 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
||||
|
||||
interface IPendingSave {
|
||||
versionId: number;
|
||||
promise: TPromise<void>;
|
||||
promise: Thenable<void>;
|
||||
}
|
||||
|
||||
interface ISaveOperation {
|
||||
promise: TPromise<void>;
|
||||
promiseValue: TValueCallback<void>;
|
||||
promiseError: ErrorCallback;
|
||||
run: () => TPromise<void>;
|
||||
promise: Thenable<void>;
|
||||
promiseResolve: () => void;
|
||||
promiseReject: (error: Error) => void;
|
||||
run: () => Thenable<void>;
|
||||
}
|
||||
|
||||
export class SaveSequentializer {
|
||||
@@ -1069,14 +1067,14 @@ export class SaveSequentializer {
|
||||
return !!this._pendingSave;
|
||||
}
|
||||
|
||||
get pendingSave(): TPromise<void> {
|
||||
get pendingSave(): Thenable<void> {
|
||||
return this._pendingSave ? this._pendingSave.promise : void 0;
|
||||
}
|
||||
|
||||
setPending(versionId: number, promise: TPromise<void>): TPromise<void> {
|
||||
setPending(versionId: number, promise: Thenable<void>): Thenable<void> {
|
||||
this._pendingSave = { versionId, promise };
|
||||
|
||||
promise.done(() => this.donePending(versionId), () => this.donePending(versionId));
|
||||
promise.then(() => this.donePending(versionId), () => this.donePending(versionId));
|
||||
|
||||
return promise;
|
||||
}
|
||||
@@ -1098,28 +1096,28 @@ export class SaveSequentializer {
|
||||
this._nextSave = void 0;
|
||||
|
||||
// Run next save and complete on the associated promise
|
||||
saveOperation.run().done(saveOperation.promiseValue, saveOperation.promiseError);
|
||||
saveOperation.run().then(saveOperation.promiseResolve, saveOperation.promiseReject);
|
||||
}
|
||||
}
|
||||
|
||||
setNext(run: () => TPromise<void>): TPromise<void> {
|
||||
setNext(run: () => Thenable<void>): Thenable<void> {
|
||||
|
||||
// this is our first next save, so we create associated promise with it
|
||||
// so that we can return a promise that completes when the save operation
|
||||
// has completed.
|
||||
if (!this._nextSave) {
|
||||
let promiseValue: TValueCallback<void>;
|
||||
let promiseError: ErrorCallback;
|
||||
const promise = new TPromise<void>((c, e) => {
|
||||
promiseValue = c;
|
||||
promiseError = e;
|
||||
let promiseResolve: () => void;
|
||||
let promiseReject: (error: Error) => void;
|
||||
const promise = new Promise<void>((resolve, reject) => {
|
||||
promiseResolve = resolve;
|
||||
promiseReject = reject;
|
||||
});
|
||||
|
||||
this._nextSave = {
|
||||
run,
|
||||
promise,
|
||||
promiseValue,
|
||||
promiseError
|
||||
promiseResolve: promiseResolve,
|
||||
promiseReject: promiseReject
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -2,11 +2,10 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { Event, Emitter, debounceEvent } from 'vs/base/common/event';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
import { dispose, IDisposable, Disposable } from 'vs/base/common/lifecycle';
|
||||
import { ITextFileEditorModel, ITextFileEditorModelManager, TextFileModelChangeEvent, StateChange, IModelLoadOrCreateOptions } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
|
||||
@@ -2,21 +2,20 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as paths from 'vs/base/common/paths';
|
||||
import * as errors from 'vs/base/common/errors';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { Event, Emitter } from 'vs/base/common/event';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
import { IResult, ITextFileOperationResult, ITextFileService, IRawTextContent, IAutoSaveConfiguration, AutoSaveMode, SaveReason, ITextFileEditorModelManager, ITextFileEditorModel, ModelState, ISaveOptions, AutoSaveContext, IWillMoveEvent } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { ConfirmResult, IRevertOptions } from 'vs/workbench/common/editor';
|
||||
import { ILifecycleService, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { ILifecycleService, ShutdownReason, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
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';
|
||||
@@ -33,7 +32,7 @@ import { IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/c
|
||||
import { createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/textModel';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { INotificationService } from 'vs/platform/notification/common/notification';
|
||||
import { isEqualOrParent, isEqual } from 'vs/base/common/resources';
|
||||
import { isEqualOrParent, isEqual, joinPath, dirname } from 'vs/base/common/resources';
|
||||
|
||||
export interface IBackupResult {
|
||||
didBackup: boolean;
|
||||
@@ -48,10 +47,10 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
|
||||
_serviceBrand: any;
|
||||
|
||||
private readonly _onFilesAssociationChange: Emitter<void> = this._register(new Emitter<void>());
|
||||
private readonly _onAutoSaveConfigurationChange: Emitter<IAutoSaveConfiguration> = this._register(new Emitter<IAutoSaveConfiguration>());
|
||||
get onAutoSaveConfigurationChange(): Event<IAutoSaveConfiguration> { return this._onAutoSaveConfigurationChange.event; }
|
||||
|
||||
private readonly _onAutoSaveConfigurationChange: Emitter<IAutoSaveConfiguration> = this._register(new Emitter<IAutoSaveConfiguration>());
|
||||
private readonly _onFilesAssociationChange: Emitter<void> = this._register(new Emitter<void>());
|
||||
get onFilesAssociationChange(): Event<void> { return this._onFilesAssociationChange.event; }
|
||||
|
||||
private readonly _onWillMove = this._register(new Emitter<IWillMoveEvent>());
|
||||
@@ -76,6 +75,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
protected environmentService: IEnvironmentService,
|
||||
private backupFileService: IBackupFileService,
|
||||
private windowsService: IWindowsService,
|
||||
protected windowService: IWindowService,
|
||||
private historyService: IHistoryService,
|
||||
contextKeyService: IContextKeyService,
|
||||
private modelService: IModelService
|
||||
@@ -99,14 +99,14 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
|
||||
abstract resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise<IRawTextContent>;
|
||||
|
||||
abstract promptForPath(defaultPath: string): TPromise<string>;
|
||||
abstract promptForPath(resource: URI, defaultPath: URI): TPromise<URI>;
|
||||
|
||||
abstract confirmSave(resources?: URI[]): TPromise<ConfirmResult>;
|
||||
|
||||
private registerListeners(): void {
|
||||
|
||||
// Lifecycle
|
||||
this.lifecycleService.onWillShutdown(event => event.veto(this.beforeShutdown(event.reason)));
|
||||
this.lifecycleService.onBeforeShutdown(event => event.veto(this.beforeShutdown(event.reason)));
|
||||
this.lifecycleService.onShutdown(this.dispose, this);
|
||||
|
||||
// Files configuration changes
|
||||
@@ -287,6 +287,10 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
return false;
|
||||
}
|
||||
|
||||
if (this.lifecycleService.phase < LifecyclePhase.Restored) {
|
||||
return false; // if editors have not restored, we are not up to speed with backups and thus should not clean them
|
||||
}
|
||||
|
||||
return this.cleanupBackupsBeforeShutdown().then(() => false, () => false);
|
||||
}
|
||||
|
||||
@@ -334,7 +338,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
|
||||
// save all dirty when enabling auto save
|
||||
if (!wasAutoSaveEnabled && this.getAutoSaveMode() !== AutoSaveMode.OFF) {
|
||||
this.saveAll().done(null, errors.onUnexpectedError);
|
||||
this.saveAll();
|
||||
}
|
||||
|
||||
// Check for change in files associations
|
||||
@@ -381,7 +385,13 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
if (options && options.force && this.fileService.canHandleResource(resource) && !this.isDirty(resource)) {
|
||||
const model = this._models.get(resource);
|
||||
if (model) {
|
||||
model.save({ force: true, reason: SaveReason.EXPLICIT }).then(() => !model.isDirty());
|
||||
if (!options) {
|
||||
options = Object.create(null);
|
||||
}
|
||||
|
||||
options.reason = SaveReason.EXPLICIT;
|
||||
|
||||
return model.save(options).then(() => !model.isDirty());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -433,7 +443,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
|
||||
// Otherwise ask user
|
||||
else {
|
||||
const targetPath = await this.promptForPath(this.suggestFileName(untitled));
|
||||
const targetPath = await this.promptForPath(untitled, this.suggestFileName(untitled));
|
||||
if (!targetPath) {
|
||||
return TPromise.as({
|
||||
results: [...fileResources, ...untitledResources].map(r => {
|
||||
@@ -444,7 +454,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
});
|
||||
}
|
||||
|
||||
targetUri = URI.file(targetPath);
|
||||
targetUri = targetPath;
|
||||
}
|
||||
|
||||
targetsForUntitled.push(targetUri);
|
||||
@@ -529,18 +539,12 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
if (target) {
|
||||
targetPromise = TPromise.wrap(target);
|
||||
} else {
|
||||
let dialogPath = resource.fsPath;
|
||||
let dialogPath = resource;
|
||||
if (resource.scheme === Schemas.untitled) {
|
||||
dialogPath = this.suggestFileName(resource);
|
||||
}
|
||||
|
||||
targetPromise = this.promptForPath(dialogPath).then(pathRaw => {
|
||||
if (pathRaw) {
|
||||
return URI.file(pathRaw);
|
||||
}
|
||||
|
||||
return void 0;
|
||||
});
|
||||
targetPromise = this.promptForPath(resource, dialogPath);
|
||||
}
|
||||
|
||||
return targetPromise.then(target => {
|
||||
@@ -623,20 +627,23 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
});
|
||||
}
|
||||
|
||||
private suggestFileName(untitledResource: URI): string {
|
||||
private suggestFileName(untitledResource: URI): URI {
|
||||
const untitledFileName = this.untitledEditorService.suggestFileName(untitledResource);
|
||||
|
||||
const lastActiveFile = this.historyService.getLastActiveFile();
|
||||
const schemeFilter = Schemas.file;
|
||||
|
||||
const lastActiveFile = this.historyService.getLastActiveFile(schemeFilter);
|
||||
if (lastActiveFile) {
|
||||
return URI.file(paths.join(paths.dirname(lastActiveFile.fsPath), untitledFileName)).fsPath;
|
||||
const lastDir = dirname(lastActiveFile);
|
||||
return joinPath(lastDir, untitledFileName);
|
||||
}
|
||||
|
||||
const lastActiveFolder = this.historyService.getLastActiveWorkspaceRoot('file');
|
||||
const lastActiveFolder = this.historyService.getLastActiveWorkspaceRoot(schemeFilter);
|
||||
if (lastActiveFolder) {
|
||||
return URI.file(paths.join(lastActiveFolder.fsPath, untitledFileName)).fsPath;
|
||||
return joinPath(lastActiveFolder, untitledFileName);
|
||||
}
|
||||
|
||||
return untitledFileName;
|
||||
return URI.file(untitledFileName);
|
||||
}
|
||||
|
||||
revert(resource: URI, options?: IRevertOptions): TPromise<boolean> {
|
||||
@@ -721,7 +728,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
this._onWillMove.fire({
|
||||
oldResource: source,
|
||||
newResource: target,
|
||||
waitUntil(p: TPromise<any>) {
|
||||
waitUntil(p: Thenable<any>) {
|
||||
waitForPromises.push(TPromise.wrap(p).then(undefined, errors.onUnexpectedError));
|
||||
}
|
||||
});
|
||||
@@ -733,7 +740,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer
|
||||
|
||||
// Handle target models if existing (if target URI is a folder, this can be multiple)
|
||||
let handleTargetModelPromise: TPromise<any> = TPromise.as(void 0);
|
||||
const dirtyTargetModels = this.getDirtyFileModels().filter(model => isEqualOrParent(model.getResource(), target, !platform.isLinux /* ignorecase */));
|
||||
const dirtyTargetModels = this.getDirtyFileModels().filter(model => isEqualOrParent(model.getResource(), target, false /* do not ignorecase, see https://github.com/Microsoft/vscode/issues/56384 */));
|
||||
if (dirtyTargetModels.length) {
|
||||
handleTargetModelPromise = this.revertAll(dirtyTargetModels.map(targetModel => targetModel.getResource()), { soft: true });
|
||||
}
|
||||
|
||||
@@ -2,10 +2,9 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the Source EULA. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
'use strict';
|
||||
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { Event } from 'vs/base/common/event';
|
||||
import { IDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IEncodingSupport, ConfirmResult, IRevertOptions } from 'vs/workbench/common/editor';
|
||||
@@ -16,7 +15,7 @@ import { ITextBufferFactory } from 'vs/editor/common/model';
|
||||
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
|
||||
|
||||
/**
|
||||
* The save error handler can be installed on the text text file editor model to install code that executes when save errors occur.
|
||||
* The save error handler can be installed on the text file editor model to install code that executes when save errors occur.
|
||||
*/
|
||||
export interface ISaveErrorHandler {
|
||||
|
||||
@@ -35,9 +34,9 @@ export interface ISaveParticipant {
|
||||
}
|
||||
|
||||
/**
|
||||
* States the text text file editor model can be in.
|
||||
* States the text file editor model can be in.
|
||||
*/
|
||||
export enum ModelState {
|
||||
export const enum ModelState {
|
||||
SAVED,
|
||||
DIRTY,
|
||||
PENDING_SAVE,
|
||||
@@ -60,7 +59,7 @@ export enum ModelState {
|
||||
ERROR
|
||||
}
|
||||
|
||||
export enum StateChange {
|
||||
export const enum StateChange {
|
||||
DIRTY,
|
||||
SAVING,
|
||||
SAVE_ERROR,
|
||||
@@ -108,7 +107,7 @@ export interface IAutoSaveConfiguration {
|
||||
autoSaveApplicationChange: boolean;
|
||||
}
|
||||
|
||||
export enum AutoSaveMode {
|
||||
export const enum AutoSaveMode {
|
||||
OFF,
|
||||
AFTER_SHORT_DELAY,
|
||||
AFTER_LONG_DELAY,
|
||||
@@ -116,14 +115,14 @@ export enum AutoSaveMode {
|
||||
ON_WINDOW_CHANGE
|
||||
}
|
||||
|
||||
export enum SaveReason {
|
||||
export const enum SaveReason {
|
||||
EXPLICIT = 1,
|
||||
AUTO = 2,
|
||||
FOCUS_CHANGE = 3,
|
||||
WINDOW_CHANGE = 4
|
||||
}
|
||||
|
||||
export enum LoadReason {
|
||||
export const enum LoadReason {
|
||||
EDITOR = 1,
|
||||
REFERENCE = 2,
|
||||
OTHER = 3
|
||||
@@ -244,7 +243,7 @@ export interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport
|
||||
|
||||
save(options?: ISaveOptions): TPromise<void>;
|
||||
|
||||
load(options?: ILoadOptions): TPromise<ITextFileEditorModel>;
|
||||
load(options?: ILoadOptions): Thenable<ITextFileEditorModel>;
|
||||
|
||||
revert(soft?: boolean): TPromise<void>;
|
||||
|
||||
@@ -254,8 +253,6 @@ export interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport
|
||||
|
||||
isResolved(): boolean;
|
||||
|
||||
isReadonly(): boolean;
|
||||
|
||||
isDisposed(): boolean;
|
||||
}
|
||||
|
||||
@@ -263,7 +260,7 @@ export interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport
|
||||
export interface IWillMoveEvent {
|
||||
oldResource: URI;
|
||||
newResource: URI;
|
||||
waitUntil(p: TPromise<any>): void;
|
||||
waitUntil(p: Thenable<any>): void;
|
||||
}
|
||||
|
||||
export interface ITextFileService extends IDisposable {
|
||||
|
||||
Reference in New Issue
Block a user