mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 22:37:41 +00:00
debt - add more configuration related things from textfiles to files config service
This commit is contained in:
parent
27eafea04a
commit
4c5dd3bc93
|
@ -17,7 +17,7 @@ import { UntitledTextEditorInput } from 'vs/workbench/common/editor/untitledText
|
|||
import { ResourceEditorInput } from 'vs/workbench/common/editor/resourceEditorInput';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TextDiffEditor } from 'vs/workbench/browser/parts/editor/textDiffEditor';
|
||||
import { ITextFileService, SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { BinaryResourceDiffEditor } from 'vs/workbench/browser/parts/editor/binaryDiffEditor';
|
||||
import { ChangeEncodingAction, ChangeEOLAction, ChangeModeAction, EditorStatus } from 'vs/workbench/browser/parts/editor/editorStatus';
|
||||
import { IWorkbenchActionRegistry, Extensions as ActionExtensions } from 'vs/workbench/common/actions';
|
||||
|
@ -53,6 +53,7 @@ import { Extensions as WorkbenchExtensions, IWorkbenchContributionsRegistry } fr
|
|||
import { LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { withNullAsUndefined } from 'vs/base/common/types';
|
||||
import { registerAndGetAmdImageURL } from 'vs/base/common/amd';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
// Register String Editor
|
||||
Registry.as<IEditorRegistry>(EditorExtensions.Editors).registerEditor(
|
||||
|
@ -113,12 +114,12 @@ interface ISerializedUntitledTextEditorInput {
|
|||
class UntitledTextEditorInputFactory implements IEditorInputFactory {
|
||||
|
||||
constructor(
|
||||
@ITextFileService private readonly textFileService: ITextFileService,
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
|
||||
) { }
|
||||
|
||||
serialize(editorInput: EditorInput): string | undefined {
|
||||
if (!this.textFileService.isHotExitEnabled) {
|
||||
if (!this.filesConfigurationService.isHotExitEnabled) {
|
||||
return undefined; // never restore untitled unless hot exit is enabled
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import { EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor';
|
|||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { EditorActivation, IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IClipboardService } from 'vs/platform/clipboard/common/clipboardService';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
/**
|
||||
* The text editor that leverages the diff text editor for the editing experience.
|
||||
|
@ -56,9 +56,9 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
|
|||
@ITextFileService textFileService: ITextFileService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IClipboardService private _clipboardService: IClipboardService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, autoSaveConfigurationService);
|
||||
super(TextDiffEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, filesConfigurationService);
|
||||
}
|
||||
|
||||
protected getEditorMemento<T>(editorGroupService: IEditorGroupsService, key: string, limit: number = 10): IEditorMemento<T> {
|
||||
|
|
|
@ -24,7 +24,7 @@ import { IEditorGroupsService, IEditorGroup } from 'vs/workbench/services/editor
|
|||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IAutoSaveConfigurationService, AutoSaveMode } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
const TEXT_EDITOR_VIEW_STATE_PREFERENCE_KEY = 'textEditorViewState';
|
||||
|
||||
|
@ -55,7 +55,7 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditor {
|
|||
@IEditorService protected editorService: IEditorService,
|
||||
@IEditorGroupsService protected editorGroupService: IEditorGroupsService,
|
||||
@IHostService private readonly hostService: IHostService,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(id, telemetryService, themeService, storageService);
|
||||
|
||||
|
@ -167,7 +167,7 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditor {
|
|||
}
|
||||
|
||||
private maybeTriggerSaveAll(reason: SaveReason): void {
|
||||
const mode = this.autoSaveConfigurationService.getAutoSaveMode();
|
||||
const mode = this.filesConfigurationService.getAutoSaveMode();
|
||||
|
||||
// Determine if we need to save all. In case of a window focus change we also save if auto save mode
|
||||
// is configured to be ON_FOCUS_CHANGE (editor focus change)
|
||||
|
|
|
@ -24,7 +24,7 @@ import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editor
|
|||
import { CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
/**
|
||||
* An editor implementation that is capable of showing the contents of resource inputs. Uses
|
||||
|
@ -43,9 +43,9 @@ export class AbstractTextResourceEditor extends BaseTextEditor {
|
|||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEditorService editorService: IEditorService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(id, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, autoSaveConfigurationService);
|
||||
super(id, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, filesConfigurationService);
|
||||
}
|
||||
|
||||
getTitle(): string | undefined {
|
||||
|
@ -208,8 +208,8 @@ export class TextResourceEditor extends AbstractTextResourceEditor {
|
|||
@IEditorService editorService: IEditorService,
|
||||
@IEditorGroupsService editorGroupService: IEditorGroupsService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(TextResourceEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, editorGroupService, textFileService, editorService, hostService, autoSaveConfigurationService);
|
||||
super(TextResourceEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, editorGroupService, textFileService, editorService, hostService, filesConfigurationService);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,7 +51,7 @@ import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/commo
|
|||
import { CancellationTokenSource, CancellationToken } from 'vs/base/common/cancellation';
|
||||
import { IStorageService } from 'vs/platform/storage/common/storage';
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { IAutoSaveConfigurationService, AutoSaveMode } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
const HELP_PREFIX = '?';
|
||||
|
||||
|
@ -737,7 +737,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
|
|||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@ILabelService labelService: ILabelService,
|
||||
@IFileService fileService: IFileService,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(editorService);
|
||||
|
||||
|
@ -755,7 +755,7 @@ export class EditorHistoryEntry extends EditorQuickOpenEntry {
|
|||
this.description = labelService.getUriLabel(resources.dirname(this.resource), { relative: true });
|
||||
this.dirty = this.resource && this.textFileService.isDirty(this.resource);
|
||||
|
||||
if (this.dirty && this.autoSaveConfigurationService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
|
||||
if (this.dirty && this.filesConfigurationService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
|
||||
this.dirty = false; // no dirty decoration if auto save is on with a short timeout
|
||||
}
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ITextFileService, TextFileModelChangeEvent, StateChange } from 'vs/work
|
|||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { IWorkbenchContribution } from 'vs/workbench/common/contributions';
|
||||
import { CONTENT_CHANGE_EVENT_BUFFER_DELAY } from 'vs/platform/files/common/files';
|
||||
import { IAutoSaveConfigurationService, IAutoSaveConfiguration } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, IAutoSaveConfiguration } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
const AUTO_SAVE_AFTER_DELAY_DISABLED_TIME = CONTENT_CHANGE_EVENT_BUFFER_DELAY + 500;
|
||||
|
||||
|
@ -22,7 +22,7 @@ export class BackupModelTracker extends Disposable implements IWorkbenchContribu
|
|||
@IBackupFileService private readonly backupFileService: IBackupFileService,
|
||||
@ITextFileService private readonly textFileService: ITextFileService,
|
||||
@IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -41,7 +41,7 @@ export class BackupModelTracker extends Disposable implements IWorkbenchContribu
|
|||
this._register(this.untitledTextEditorService.onDidDisposeModel(e => this.discardBackup(e)));
|
||||
|
||||
// Listen to auto save config changes
|
||||
this._register(this.autoSaveConfigurationService.onAutoSaveConfigurationChange(c => this.onAutoSaveConfigurationChange(c)));
|
||||
this._register(this.filesConfigurationService.onAutoSaveConfigurationChange(c => this.onAutoSaveConfigurationChange(c)));
|
||||
}
|
||||
|
||||
private onAutoSaveConfigurationChange(configuration: IAutoSaveConfiguration): void {
|
||||
|
|
|
@ -32,7 +32,7 @@ import { IEditorGroupView } from 'vs/workbench/browser/parts/editor/editor';
|
|||
import { createErrorWithActions } from 'vs/base/common/errorsWithActions';
|
||||
import { MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { EditorActivation, IEditorOptions } from 'vs/platform/editor/common/editor';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
/**
|
||||
* An implementation of editor for file system resources.
|
||||
|
@ -58,9 +58,9 @@ export class TextFileEditor extends BaseTextEditor {
|
|||
@ITextFileService textFileService: ITextFileService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IExplorerService private readonly explorerService: IExplorerService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, autoSaveConfigurationService);
|
||||
super(TextFileEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, filesConfigurationService);
|
||||
|
||||
this.updateRestoreViewStateConfiguration();
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ import { isMacintosh } from 'vs/base/common/platform';
|
|||
import { FilesExplorerFocusCondition, ExplorerRootContext, ExplorerFolderContext, ExplorerResourceNotReadonlyContext, ExplorerResourceCut, IExplorerService, ExplorerResourceMoveableToTrash, ExplorerViewletVisibleContext } from 'vs/workbench/contrib/files/common/files';
|
||||
import { ADD_ROOT_FOLDER_COMMAND_ID, ADD_ROOT_FOLDER_LABEL } from 'vs/workbench/browser/actions/workspaceCommands';
|
||||
import { CLOSE_SAVED_EDITORS_COMMAND_ID, CLOSE_EDITORS_IN_GROUP_COMMAND_ID, CLOSE_EDITOR_COMMAND_ID, CLOSE_OTHER_EDITORS_IN_GROUP_COMMAND_ID } from 'vs/workbench/browser/parts/editor/editorCommands';
|
||||
import { AutoSaveContext } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { AutoSaveContext } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { ResourceContextKey } from 'vs/workbench/common/resources';
|
||||
import { WorkbenchListDoubleSelection } from 'vs/platform/list/browser/listService';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
|
|
|
@ -45,7 +45,7 @@ import { ExplorerItem, NewExplorerItem } from 'vs/workbench/contrib/files/common
|
|||
import { onUnexpectedError, getErrorMessage } from 'vs/base/common/errors';
|
||||
import { asDomUri, triggerDownload } from 'vs/base/browser/dom';
|
||||
import { mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
import { IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
|
||||
export const NEW_FILE_COMMAND_ID = 'explorer.newFile';
|
||||
|
@ -496,13 +496,13 @@ export class ToggleAutoSaveAction extends Action {
|
|||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): Promise<any> {
|
||||
return this.autoSaveConfigurationService.toggleAutoSave();
|
||||
return this.filesConfigurationService.toggleAutoSave();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@ import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
|||
import { Disposable, MutableDisposable } from 'vs/base/common/lifecycle';
|
||||
import { IActivityService, NumberBadge } from 'vs/workbench/services/activity/common/activity';
|
||||
import { IWorkingCopyService, IWorkingCopy, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IAutoSaveConfigurationService, AutoSaveMode } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
export class DirtyFilesIndicator extends Disposable implements IWorkbenchContribution {
|
||||
private readonly badgeHandle = this._register(new MutableDisposable());
|
||||
|
@ -25,7 +25,7 @@ export class DirtyFilesIndicator extends Disposable implements IWorkbenchContrib
|
|||
@ILifecycleService private readonly lifecycleService: ILifecycleService,
|
||||
@IActivityService private readonly activityService: IActivityService,
|
||||
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -43,7 +43,7 @@ export class DirtyFilesIndicator extends Disposable implements IWorkbenchContrib
|
|||
|
||||
private onWorkingCopyDidChangeDirty(copy: IWorkingCopy): void {
|
||||
const gotDirty = copy.isDirty();
|
||||
if (gotDirty && !!(copy.capabilities & WorkingCopyCapabilities.AutoSave) && this.autoSaveConfigurationService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
|
||||
if (gotDirty && !!(copy.capabilities & WorkingCopyCapabilities.AutoSave) && this.filesConfigurationService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
|
||||
return; // do not indicate dirty of working copies that are auto saved after short delay
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import { IReference } from 'vs/base/common/lifecycle';
|
|||
import { ITextModelService } from 'vs/editor/common/services/resolverService';
|
||||
import { FILE_EDITOR_INPUT_ID, TEXT_FILE_EDITOR_ID, BINARY_FILE_EDITOR_ID } from 'vs/workbench/contrib/files/common/files';
|
||||
import { ILabelService } from 'vs/platform/label/common/label';
|
||||
import { IAutoSaveConfigurationService, AutoSaveMode } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
const enum ForceOpenAs {
|
||||
None,
|
||||
|
@ -51,7 +51,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
|
|||
@ITextModelService private readonly textModelResolverService: ITextModelService,
|
||||
@ILabelService private readonly labelService: ILabelService,
|
||||
@IFileService private readonly fileService: IFileService,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -236,7 +236,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput {
|
|||
return true; // always indicate dirty state if we are in conflict or error state
|
||||
}
|
||||
|
||||
if (this.autoSaveConfigurationService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
|
||||
if (this.filesConfigurationService.getAutoSaveMode() === AutoSaveMode.AFTER_SHORT_DELAY) {
|
||||
return false; // fast auto save enabled so we do not declare dirty
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import { IHostService } from 'vs/workbench/services/host/browser/host';
|
|||
import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences';
|
||||
import { IExplorerService } from 'vs/workbench/contrib/files/common/files';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
/**
|
||||
* An implementation of editor for file system resources.
|
||||
|
@ -48,9 +48,9 @@ export class NativeTextFileEditor extends TextFileEditor {
|
|||
@IPreferencesService private readonly preferencesService: IPreferencesService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IExplorerService explorerService: IExplorerService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(telemetryService, fileService, viewletService, instantiationService, contextService, storageService, configurationService, editorService, themeService, editorGroupService, textFileService, hostService, explorerService, autoSaveConfigurationService);
|
||||
super(telemetryService, fileService, viewletService, instantiationService, contextService, storageService, configurationService, editorService, themeService, editorGroupService, textFileService, hostService, explorerService, filesConfigurationService);
|
||||
}
|
||||
|
||||
protected handleSetInputError(error: Error, input: FileEditorInput, options: EditorOptions | undefined): void {
|
||||
|
|
|
@ -20,7 +20,7 @@ import { LOG_SCHEME, IFileOutputChannelDescriptor } from 'vs/workbench/contrib/o
|
|||
import { IEditorGroupsService } from 'vs/workbench/services/editor/common/editorGroupsService';
|
||||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
export class LogViewerInput extends ResourceEditorInput {
|
||||
|
||||
|
@ -56,9 +56,9 @@ export class LogViewer extends AbstractTextResourceEditor {
|
|||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEditorService editorService: IEditorService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(LogViewer.LOG_VIEWER_EDITOR_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, editorService, hostService, autoSaveConfigurationService);
|
||||
super(LogViewer.LOG_VIEWER_EDITOR_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, editorService, hostService, filesConfigurationService);
|
||||
}
|
||||
|
||||
protected getConfigurationOverrides(): IEditorOptions {
|
||||
|
|
|
@ -26,7 +26,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
|
|||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { CursorChangeReason } from 'vs/editor/common/controller/cursorEvents';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
export class OutputPanel extends AbstractTextResourceEditor {
|
||||
private actions: IAction[] | undefined;
|
||||
|
@ -46,9 +46,9 @@ export class OutputPanel extends AbstractTextResourceEditor {
|
|||
@ITextFileService textFileService: ITextFileService,
|
||||
@IEditorService editorService: IEditorService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(OUTPUT_PANEL_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, editorService, hostService, autoSaveConfigurationService);
|
||||
super(OUTPUT_PANEL_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, textFileService, editorService, hostService, filesConfigurationService);
|
||||
|
||||
this.scopedInstantiationService = instantiationService;
|
||||
}
|
||||
|
|
|
@ -55,7 +55,7 @@ import { DefaultSettingsEditorModel, SettingsEditorModel } from 'vs/workbench/se
|
|||
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
|
||||
import { IHostService } from 'vs/workbench/services/host/browser/host';
|
||||
import { withNullAsUndefined, withUndefinedAsNull, assertIsDefined } from 'vs/base/common/types';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
export class PreferencesEditor extends BaseEditor {
|
||||
|
||||
|
@ -983,9 +983,9 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
|
|||
@IEditorGroupsService editorGroupService: IEditorGroupsService,
|
||||
@IEditorService editorService: IEditorService,
|
||||
@IHostService hostService: IHostService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, autoSaveConfigurationService);
|
||||
super(DefaultPreferencesEditor.ID, telemetryService, instantiationService, storageService, configurationService, themeService, textFileService, editorService, editorGroupService, hostService, filesConfigurationService);
|
||||
}
|
||||
|
||||
private static _getContributions(): IEditorContributionDescription[] {
|
||||
|
|
|
@ -9,8 +9,10 @@ import { Event, Emitter } from 'vs/base/common/event';
|
|||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { RawContextKey, IContextKey, IContextKeyService } from 'vs/platform/contextkey/common/contextkey';
|
||||
import { IConfigurationService, ConfigurationTarget } from 'vs/platform/configuration/common/configuration';
|
||||
import { IFilesConfiguration, AutoSaveConfiguration } from 'vs/platform/files/common/files';
|
||||
import { IFilesConfiguration, AutoSaveConfiguration, HotExitConfiguration } from 'vs/platform/files/common/files';
|
||||
import { isUndefinedOrNull } from 'vs/base/common/types';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { equals } from 'vs/base/common/objects';
|
||||
|
||||
export const AutoSaveContext = new RawContextKey<string>('config.files.autoSave', undefined);
|
||||
|
||||
|
@ -28,12 +30,14 @@ export const enum AutoSaveMode {
|
|||
ON_WINDOW_CHANGE
|
||||
}
|
||||
|
||||
export const IAutoSaveConfigurationService = createDecorator<IAutoSaveConfigurationService>('autoSaveConfigurationService');
|
||||
export const IFilesConfigurationService = createDecorator<IFilesConfigurationService>('filesConfigurationService');
|
||||
|
||||
export interface IAutoSaveConfigurationService {
|
||||
export interface IFilesConfigurationService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
//#region Auto Save
|
||||
|
||||
readonly onAutoSaveConfigurationChange: Event<IAutoSaveConfiguration>;
|
||||
|
||||
getAutoSaveMode(): AutoSaveMode;
|
||||
|
@ -41,30 +45,50 @@ export interface IAutoSaveConfigurationService {
|
|||
getAutoSaveConfiguration(): IAutoSaveConfiguration;
|
||||
|
||||
toggleAutoSave(): Promise<void>;
|
||||
|
||||
//#endregion
|
||||
|
||||
readonly onFilesAssociationChange: Event<void>;
|
||||
|
||||
readonly isHotExitEnabled: boolean;
|
||||
|
||||
readonly hotExitConfiguration: string | undefined;
|
||||
}
|
||||
|
||||
export class AutoSaveConfigurationService extends Disposable implements IAutoSaveConfigurationService {
|
||||
export class FilesConfigurationService extends Disposable implements IFilesConfigurationService {
|
||||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
private readonly _onAutoSaveConfigurationChange = this._register(new Emitter<IAutoSaveConfiguration>());
|
||||
readonly onAutoSaveConfigurationChange = this._onAutoSaveConfigurationChange.event;
|
||||
|
||||
private readonly _onFilesAssociationChange = this._register(new Emitter<void>());
|
||||
readonly onFilesAssociationChange = this._onFilesAssociationChange.event;
|
||||
|
||||
private configuredAutoSaveDelay?: number;
|
||||
private configuredAutoSaveOnFocusChange: boolean | undefined;
|
||||
private configuredAutoSaveOnWindowChange: boolean | undefined;
|
||||
|
||||
private autoSaveContext: IContextKey<string>;
|
||||
|
||||
private currentFilesAssociationConfig: { [key: string]: string; };
|
||||
|
||||
private currentHotExitConfig: string;
|
||||
|
||||
constructor(
|
||||
@IContextKeyService contextKeyService: IContextKeyService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IWorkbenchEnvironmentService private readonly environmentService: IWorkbenchEnvironmentService
|
||||
) {
|
||||
super();
|
||||
|
||||
this.autoSaveContext = AutoSaveContext.bindTo(contextKeyService);
|
||||
|
||||
const configuration = configurationService.getValue<IFilesConfiguration>();
|
||||
|
||||
this.currentFilesAssociationConfig = configuration?.files?.associations;
|
||||
this.currentHotExitConfig = configuration?.files?.hotExit || HotExitConfiguration.ON_EXIT;
|
||||
|
||||
this.onFilesConfigurationChange(configuration);
|
||||
|
||||
this.registerListeners();
|
||||
|
@ -80,7 +104,9 @@ export class AutoSaveConfigurationService extends Disposable implements IAutoSav
|
|||
}));
|
||||
}
|
||||
|
||||
private onFilesConfigurationChange(configuration: IFilesConfiguration): void {
|
||||
protected onFilesConfigurationChange(configuration: IFilesConfiguration): void {
|
||||
|
||||
// Auto Save
|
||||
const autoSaveMode = configuration?.files?.autoSave || AutoSaveConfiguration.OFF;
|
||||
this.autoSaveContext.set(autoSaveMode);
|
||||
switch (autoSaveMode) {
|
||||
|
@ -111,6 +137,21 @@ export class AutoSaveConfigurationService extends Disposable implements IAutoSav
|
|||
|
||||
// Emit as event
|
||||
this._onAutoSaveConfigurationChange.fire(this.getAutoSaveConfiguration());
|
||||
|
||||
// Check for change in files associations
|
||||
const filesAssociation = configuration?.files?.associations;
|
||||
if (!equals(this.currentFilesAssociationConfig, filesAssociation)) {
|
||||
this.currentFilesAssociationConfig = filesAssociation;
|
||||
this._onFilesAssociationChange.fire();
|
||||
}
|
||||
|
||||
// Hot exit
|
||||
const hotExitMode = configuration?.files?.hotExit;
|
||||
if (hotExitMode === HotExitConfiguration.OFF || hotExitMode === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
|
||||
this.currentHotExitConfig = hotExitMode;
|
||||
} else {
|
||||
this.currentHotExitConfig = HotExitConfiguration.ON_EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
getAutoSaveMode(): AutoSaveMode {
|
||||
|
@ -153,6 +194,14 @@ export class AutoSaveConfigurationService extends Disposable implements IAutoSav
|
|||
|
||||
return this.configurationService.updateValue('files.autoSave', newAutoSaveValue, ConfigurationTarget.USER);
|
||||
}
|
||||
|
||||
get isHotExitEnabled(): boolean {
|
||||
return !this.environmentService.isExtensionDevelopment && this.currentHotExitConfig !== HotExitConfiguration.OFF;
|
||||
}
|
||||
|
||||
get hotExitConfiguration(): string {
|
||||
return this.currentHotExitConfig;
|
||||
}
|
||||
}
|
||||
|
||||
registerSingleton(IAutoSaveConfigurationService, AutoSaveConfigurationService);
|
||||
registerSingleton(IFilesConfigurationService, FilesConfigurationService);
|
|
@ -35,7 +35,7 @@ export class BrowserTextFileService extends AbstractTextFileService {
|
|||
return false; // no dirty: no veto
|
||||
}
|
||||
|
||||
if (!this.isHotExitEnabled) {
|
||||
if (!this.filesConfigurationService.isHotExitEnabled) {
|
||||
return true; // dirty without backup: veto
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
|
||||
import * as nls from 'vs/nls';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import * as objects from 'vs/base/common/objects';
|
||||
import { Emitter, AsyncEmitter } from 'vs/base/common/event';
|
||||
import * as platform from 'vs/base/common/platform';
|
||||
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
|
||||
|
@ -13,8 +12,7 @@ import { IResult, ITextFileOperationResult, ITextFileService, ITextFileStreamCon
|
|||
import { ConfirmResult, IRevertOptions } from 'vs/workbench/common/editor';
|
||||
import { ILifecycleService, ShutdownReason, LifecyclePhase } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IWorkspaceContextService, WorkbenchState } from 'vs/platform/workspace/common/workspace';
|
||||
import { IFileService, IFilesConfiguration, FileOperationError, FileOperationResult, HotExitConfiguration, IFileStatWithMetadata, ICreateFileOptions, FileOperation } from 'vs/platform/files/common/files';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IFileService, FileOperationError, FileOperationResult, HotExitConfiguration, IFileStatWithMetadata, ICreateFileOptions, FileOperation } from 'vs/platform/files/common/files';
|
||||
import { Disposable } from 'vs/base/common/lifecycle';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
|
@ -37,7 +35,7 @@ import { VSBuffer } from 'vs/base/common/buffer';
|
|||
import { ITextSnapshot } from 'vs/editor/common/model';
|
||||
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
|
||||
import { PLAINTEXT_MODE_ID } from 'vs/editor/common/modes/modesRegistry';
|
||||
import { IAutoSaveConfigurationService, AutoSaveMode } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, AutoSaveMode } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
/**
|
||||
* The workbench file service implementation implements the raw file service spec and adds additional methods on top.
|
||||
|
@ -48,9 +46,6 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
|
||||
//#region events
|
||||
|
||||
private readonly _onFilesAssociationChange = this._register(new Emitter<void>());
|
||||
readonly onFilesAssociationChange = this._onFilesAssociationChange.event;
|
||||
|
||||
private _onWillRunOperation = this._register(new AsyncEmitter<FileOperationWillRunEvent>());
|
||||
readonly onWillRunOperation = this._onWillRunOperation.event;
|
||||
|
||||
|
@ -64,17 +59,12 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
|
||||
abstract get encoding(): IResourceEncodings;
|
||||
|
||||
private currentFilesAssociationConfig: { [key: string]: string; };
|
||||
|
||||
private configuredHotExit: string | undefined;
|
||||
|
||||
constructor(
|
||||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@IFileService protected readonly fileService: IFileService,
|
||||
@IUntitledTextEditorService protected readonly untitledTextEditorService: IUntitledTextEditorService,
|
||||
@ILifecycleService private readonly lifecycleService: ILifecycleService,
|
||||
@IInstantiationService protected readonly instantiationService: IInstantiationService,
|
||||
@IConfigurationService private readonly configurationService: IConfigurationService,
|
||||
@IModeService private readonly modeService: IModeService,
|
||||
@IModelService private readonly modelService: IModelService,
|
||||
@IWorkbenchEnvironmentService protected readonly environmentService: IWorkbenchEnvironmentService,
|
||||
|
@ -85,15 +75,12 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
@IFileDialogService private readonly fileDialogService: IFileDialogService,
|
||||
@IEditorService private readonly editorService: IEditorService,
|
||||
@ITextResourceConfigurationService protected readonly textResourceConfigurationService: ITextResourceConfigurationService,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService protected readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super();
|
||||
|
||||
this._models = this._register(instantiationService.createInstance(TextFileEditorModelManager));
|
||||
|
||||
const configuration = configurationService.getValue<IFilesConfiguration>();
|
||||
this.currentFilesAssociationConfig = configuration?.files?.associations;
|
||||
|
||||
this.registerListeners();
|
||||
}
|
||||
|
||||
|
@ -105,21 +92,14 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
this.lifecycleService.onBeforeShutdown(event => event.veto(this.onBeforeShutdown(event.reason)));
|
||||
this.lifecycleService.onShutdown(this.dispose, this);
|
||||
|
||||
// Files configuration changes
|
||||
this._register(this.configurationService.onDidChangeConfiguration(e => {
|
||||
if (e.affectsConfiguration('files')) {
|
||||
this.onFilesConfigurationChange(this.configurationService.getValue<IFilesConfiguration>());
|
||||
}
|
||||
}));
|
||||
|
||||
// Auto save changes
|
||||
this._register(this.autoSaveConfigurationService.onAutoSaveConfigurationChange(() => this.onAutoSaveConfigurationChange()));
|
||||
this._register(this.filesConfigurationService.onAutoSaveConfigurationChange(() => this.onAutoSaveConfigurationChange()));
|
||||
}
|
||||
|
||||
private onAutoSaveConfigurationChange(): void {
|
||||
|
||||
// save all dirty when enabling auto save
|
||||
if (this.autoSaveConfigurationService.getAutoSaveMode() !== AutoSaveMode.OFF) {
|
||||
if (this.filesConfigurationService.getAutoSaveMode() !== AutoSaveMode.OFF) {
|
||||
this.saveAll();
|
||||
}
|
||||
}
|
||||
|
@ -132,7 +112,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
|
||||
// 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
|
||||
if (this.autoSaveConfigurationService.getAutoSaveMode() !== AutoSaveMode.OFF) {
|
||||
if (this.filesConfigurationService.getAutoSaveMode() !== AutoSaveMode.OFF) {
|
||||
return this.saveAll(false /* files only */, { skipSaveParticipants: true }).then(() => {
|
||||
|
||||
// If we still have dirty files, we either have untitled ones or files that cannot be saved
|
||||
|
@ -156,7 +136,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
private handleDirtyBeforeShutdown(dirty: URI[], reason: ShutdownReason): boolean | Promise<boolean> {
|
||||
|
||||
// If hot exit is enabled, backup dirty files and allow to exit without confirmation
|
||||
if (this.isHotExitEnabled) {
|
||||
if (this.filesConfigurationService.isHotExitEnabled) {
|
||||
return this.backupBeforeShutdown(dirty, reason).then(didBackup => {
|
||||
if (didBackup) {
|
||||
return this.noVeto({ cleanUpBackups: false }); // no veto and no backup cleanup (since backup was successful)
|
||||
|
@ -184,7 +164,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
let doBackup: boolean | undefined;
|
||||
switch (reason) {
|
||||
case ShutdownReason.CLOSE:
|
||||
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.configuredHotExit === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
|
||||
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.filesConfigurationService.hotExitConfiguration === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
|
||||
doBackup = true; // backup if a folder is open and onExitAndWindowClose is configured
|
||||
} else if (await this.getWindowCount() > 1 || platform.isMacintosh) {
|
||||
doBackup = false; // do not backup if a window is closed that does not cause quitting of the application
|
||||
|
@ -202,7 +182,7 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
break;
|
||||
|
||||
case ShutdownReason.LOAD:
|
||||
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.configuredHotExit === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
|
||||
if (this.contextService.getWorkbenchState() !== WorkbenchState.EMPTY && this.filesConfigurationService.hotExitConfiguration === 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
|
||||
|
@ -303,24 +283,6 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
await this.backupFileService.discardAllWorkspaceBackups();
|
||||
}
|
||||
|
||||
protected onFilesConfigurationChange(configuration: IFilesConfiguration): void {
|
||||
|
||||
// Check for change in files associations
|
||||
const filesAssociation = configuration?.files?.associations;
|
||||
if (!objects.equals(this.currentFilesAssociationConfig, filesAssociation)) {
|
||||
this.currentFilesAssociationConfig = filesAssociation;
|
||||
this._onFilesAssociationChange.fire();
|
||||
}
|
||||
|
||||
// Hot exit
|
||||
const hotExitMode = configuration?.files?.hotExit;
|
||||
if (hotExitMode === HotExitConfiguration.OFF || hotExitMode === HotExitConfiguration.ON_EXIT_AND_WINDOW_CLOSE) {
|
||||
this.configuredHotExit = hotExitMode;
|
||||
} else {
|
||||
this.configuredHotExit = HotExitConfiguration.ON_EXIT;
|
||||
}
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
//#region primitives (read, create, move, delete, update)
|
||||
|
@ -969,14 +931,6 @@ export abstract class AbstractTextFileService extends Disposable implements ITex
|
|||
|
||||
//#endregion
|
||||
|
||||
//#region config
|
||||
|
||||
get isHotExitEnabled(): boolean {
|
||||
return !this.environmentService.isExtensionDevelopment && this.configuredHotExit !== HotExitConfiguration.OFF;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
dispose(): void {
|
||||
|
||||
// Clear all caches
|
||||
|
|
|
@ -30,7 +30,7 @@ import { isEqual, isEqualOrParent, extname, basename, joinPath } from 'vs/base/c
|
|||
import { onUnexpectedError } from 'vs/base/common/errors';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IWorkingCopyService, WorkingCopyCapabilities } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IAutoSaveConfigurationService, IAutoSaveConfiguration } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, IAutoSaveConfiguration } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
export interface IBackupMetaData {
|
||||
mtime: number;
|
||||
|
@ -123,11 +123,11 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
|||
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
|
||||
@ILogService private readonly logService: ILogService,
|
||||
@IWorkingCopyService private readonly workingCopyService: IWorkingCopyService,
|
||||
@IAutoSaveConfigurationService private readonly autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService private readonly filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(modelService, modeService);
|
||||
|
||||
this.updateAutoSaveConfiguration(autoSaveConfigurationService.getAutoSaveConfiguration());
|
||||
this.updateAutoSaveConfiguration(filesConfigurationService.getAutoSaveConfiguration());
|
||||
|
||||
// Make known to working copy service
|
||||
this._register(this.workingCopyService.registerWorkingCopy(this));
|
||||
|
@ -137,8 +137,8 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
|
|||
|
||||
private registerListeners(): void {
|
||||
this._register(this.fileService.onFileChanges(e => this.onFileChanges(e)));
|
||||
this._register(this.autoSaveConfigurationService.onAutoSaveConfigurationChange(config => this.updateAutoSaveConfiguration(config)));
|
||||
this._register(this.textFileService.onFilesAssociationChange(e => this.onFilesAssociationChange()));
|
||||
this._register(this.filesConfigurationService.onAutoSaveConfigurationChange(config => this.updateAutoSaveConfiguration(config)));
|
||||
this._register(this.filesConfigurationService.onFilesAssociationChange(e => this.onFilesAssociationChange()));
|
||||
this._register(this.onDidStateChange(e => this.onStateChange(e)));
|
||||
}
|
||||
|
||||
|
|
|
@ -22,10 +22,6 @@ export interface ITextFileService extends IDisposable {
|
|||
|
||||
_serviceBrand: undefined;
|
||||
|
||||
readonly onFilesAssociationChange: Event<void>;
|
||||
|
||||
readonly isHotExitEnabled: boolean;
|
||||
|
||||
/**
|
||||
* An event that is fired before attempting a certain file operation.
|
||||
*/
|
||||
|
|
|
@ -31,7 +31,6 @@ import { IElectronService } from 'vs/platform/electron/node/electron';
|
|||
import { IUntitledTextEditorService } from 'vs/workbench/services/untitled/common/untitledTextEditorService';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
|
||||
import { IModeService } from 'vs/editor/common/services/modeService';
|
||||
import { IModelService } from 'vs/editor/common/services/modelService';
|
||||
import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/common/environmentService';
|
||||
|
@ -42,7 +41,7 @@ import { IDialogService, IFileDialogService } from 'vs/platform/dialogs/common/d
|
|||
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
|
||||
import { ConfirmResult } from 'vs/workbench/common/editor';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import { IAutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
export class NativeTextFileService extends AbstractTextFileService {
|
||||
|
||||
|
@ -52,7 +51,6 @@ export class NativeTextFileService extends AbstractTextFileService {
|
|||
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
|
||||
|
@ -65,9 +63,9 @@ export class NativeTextFileService extends AbstractTextFileService {
|
|||
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
|
||||
@IElectronService private readonly electronService: IElectronService,
|
||||
@IProductService private readonly productService: IProductService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(contextService, fileService, untitledTextEditorService, lifecycleService, instantiationService, configurationService, modeService, modelService, environmentService, notificationService, backupFileService, historyService, dialogService, fileDialogService, editorService, textResourceConfigurationService, autoSaveConfigurationService);
|
||||
super(contextService, fileService, untitledTextEditorService, lifecycleService, instantiationService, modeService, modelService, environmentService, notificationService, backupFileService, historyService, dialogService, fileDialogService, editorService, textResourceConfigurationService, filesConfigurationService);
|
||||
}
|
||||
|
||||
private _encoding: EncodingOracle | undefined;
|
||||
|
|
|
@ -7,7 +7,7 @@ import * as sinon from 'sinon';
|
|||
import * as platform from 'vs/base/common/platform';
|
||||
import { URI } from 'vs/base/common/uri';
|
||||
import { ILifecycleService, BeforeShutdownEvent, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import { workbenchInstantiationService, TestLifecycleService, TestTextFileService, TestContextService, TestFileService, TestElectronService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { workbenchInstantiationService, TestLifecycleService, TestTextFileService, TestContextService, TestFileService, TestElectronService, TestFilesConfigurationService } from 'vs/workbench/test/workbenchTestServices';
|
||||
import { toResource } from 'vs/base/test/common/utils';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel';
|
||||
|
@ -21,11 +21,13 @@ import { IModelService } from 'vs/editor/common/services/modelService';
|
|||
import { ModelServiceImpl } from 'vs/editor/common/services/modelServiceImpl';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { IElectronService } from 'vs/platform/electron/node/electron';
|
||||
import { IFilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
class ServiceAccessor {
|
||||
constructor(
|
||||
@ILifecycleService public lifecycleService: TestLifecycleService,
|
||||
@ITextFileService public textFileService: TestTextFileService,
|
||||
@IFilesConfigurationService public filesConfigurationService: TestFilesConfigurationService,
|
||||
@IUntitledTextEditorService public untitledTextEditorService: IUntitledTextEditorService,
|
||||
@IWorkspaceContextService public contextService: TestContextService,
|
||||
@IModelService public modelService: ModelServiceImpl,
|
||||
|
@ -102,7 +104,7 @@ suite('Files - TextFileService', () => {
|
|||
|
||||
const service = accessor.textFileService;
|
||||
service.setConfirmResult(ConfirmResult.DONT_SAVE);
|
||||
service.onFilesConfigurationChange({ files: { hotExit: 'off' } });
|
||||
accessor.filesConfigurationService.onFilesConfigurationChange({ files: { hotExit: 'off' } });
|
||||
|
||||
await model.load();
|
||||
model.textEditorModel!.setValue('foo');
|
||||
|
@ -128,7 +130,7 @@ suite('Files - TextFileService', () => {
|
|||
|
||||
const service = accessor.textFileService;
|
||||
service.setConfirmResult(ConfirmResult.SAVE);
|
||||
service.onFilesConfigurationChange({ files: { hotExit: 'off' } });
|
||||
accessor.filesConfigurationService.onFilesConfigurationChange({ files: { hotExit: 'off' } });
|
||||
|
||||
await model.load();
|
||||
model.textEditorModel!.setValue('foo');
|
||||
|
@ -417,7 +419,7 @@ suite('Files - TextFileService', () => {
|
|||
|
||||
const service = accessor.textFileService;
|
||||
// Set hot exit config
|
||||
service.onFilesConfigurationChange({ files: { hotExit: setting } });
|
||||
accessor.filesConfigurationService.onFilesConfigurationChange({ files: { hotExit: setting } });
|
||||
// Set empty workspace if required
|
||||
if (!workspace) {
|
||||
accessor.contextService.setWorkspace(new Workspace('empty:1508317022751'));
|
||||
|
|
|
@ -93,7 +93,7 @@ import { IEmptyWindowBackupInfo } from 'vs/platform/backup/node/backup';
|
|||
import { IDialogMainService } from 'vs/platform/dialogs/electron-main/dialogs';
|
||||
import { find } from 'vs/base/common/arrays';
|
||||
import { WorkingCopyService, IWorkingCopyService } from 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import { IAutoSaveConfigurationService, AutoSaveConfigurationService } from 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import { IFilesConfigurationService, FilesConfigurationService } from 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
export function createFileInput(instantiationService: IInstantiationService, resource: URI): FileEditorInput {
|
||||
return instantiationService.createInstance(FileEditorInput, resource, undefined, undefined);
|
||||
|
@ -201,7 +201,6 @@ export class TestTextFileService extends NativeTextFileService {
|
|||
@IUntitledTextEditorService untitledTextEditorService: IUntitledTextEditorService,
|
||||
@ILifecycleService lifecycleService: ILifecycleService,
|
||||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IConfigurationService configurationService: IConfigurationService,
|
||||
@IModeService modeService: IModeService,
|
||||
@IModelService modelService: IModelService,
|
||||
@IWorkbenchEnvironmentService environmentService: IWorkbenchEnvironmentService,
|
||||
|
@ -214,7 +213,7 @@ export class TestTextFileService extends NativeTextFileService {
|
|||
@ITextResourceConfigurationService textResourceConfigurationService: ITextResourceConfigurationService,
|
||||
@IElectronService electronService: IElectronService,
|
||||
@IProductService productService: IProductService,
|
||||
@IAutoSaveConfigurationService autoSaveConfigurationService: IAutoSaveConfigurationService
|
||||
@IFilesConfigurationService filesConfigurationService: IFilesConfigurationService
|
||||
) {
|
||||
super(
|
||||
contextService,
|
||||
|
@ -222,7 +221,6 @@ export class TestTextFileService extends NativeTextFileService {
|
|||
untitledTextEditorService,
|
||||
lifecycleService,
|
||||
instantiationService,
|
||||
configurationService,
|
||||
modeService,
|
||||
modelService,
|
||||
environmentService,
|
||||
|
@ -235,7 +233,7 @@ export class TestTextFileService extends NativeTextFileService {
|
|||
textResourceConfigurationService,
|
||||
electronService,
|
||||
productService,
|
||||
autoSaveConfigurationService
|
||||
filesConfigurationService
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -285,10 +283,6 @@ export class TestTextFileService extends NativeTextFileService {
|
|||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
public onFilesConfigurationChange(configuration: any): void {
|
||||
super.onFilesConfigurationChange(configuration);
|
||||
}
|
||||
|
||||
protected cleanupBackupsBeforeShutdown(): Promise<void> {
|
||||
this.cleanupBackupsBeforeShutdownCalled = true;
|
||||
return Promise.resolve();
|
||||
|
@ -304,7 +298,7 @@ export function workbenchInstantiationService(): IInstantiationService {
|
|||
instantiationService.stub(IWorkspaceContextService, workspaceContextService);
|
||||
const configService = new TestConfigurationService();
|
||||
instantiationService.stub(IConfigurationService, configService);
|
||||
instantiationService.stub(IAutoSaveConfigurationService, new AutoSaveConfigurationService(contextKeyService, configService));
|
||||
instantiationService.stub(IFilesConfigurationService, new TestFilesConfigurationService(contextKeyService, configService, TestEnvironmentService));
|
||||
instantiationService.stub(ITextResourceConfigurationService, new TestTextResourceConfigurationService(configService));
|
||||
instantiationService.stub(IUntitledTextEditorService, instantiationService.createInstance(UntitledTextEditorService));
|
||||
instantiationService.stub(IStorageService, new TestStorageService());
|
||||
|
@ -1471,3 +1465,10 @@ export class TestDialogMainService implements IDialogMainService {
|
|||
}
|
||||
|
||||
export class TestWorkingCopyService extends WorkingCopyService { }
|
||||
|
||||
export class TestFilesConfigurationService extends FilesConfigurationService {
|
||||
|
||||
onFilesConfigurationChange(configuration: any): void {
|
||||
super.onFilesConfigurationChange(configuration);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ import 'vs/workbench/services/userDataSync/common/settingsMergeService';
|
|||
import 'vs/workbench/services/path/common/remotePathService';
|
||||
import 'vs/workbench/services/remote/common/remoteExplorerService';
|
||||
import 'vs/workbench/services/workingCopy/common/workingCopyService';
|
||||
import 'vs/workbench/services/autoSaveConfiguration/common/autoSaveConfigurationService';
|
||||
import 'vs/workbench/services/filesConfiguration/common/filesConfigurationService';
|
||||
|
||||
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
||||
import { ExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionGalleryService';
|
||||
|
|
Loading…
Reference in a new issue