mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 11:08:51 +01:00
first cut of handling dirty editors on close
This commit is contained in:
@@ -9,13 +9,15 @@ import URI from 'vs/base/common/uri';
|
||||
import {isUnspecific, guessMimeTypes, MIME_TEXT, suggestFilename} from 'vs/base/common/mime';
|
||||
import labels = require('vs/base/common/labels');
|
||||
import paths = require('vs/base/common/paths');
|
||||
import {UntitledEditorInput as AbstractUntitledEditorInput, EditorModel, EncodingMode, IInputStatus} from 'vs/workbench/common/editor';
|
||||
import {UntitledEditorInput as AbstractUntitledEditorInput, EditorModel, EncodingMode, IInputStatus, ConfirmResult} from 'vs/workbench/common/editor';
|
||||
import {UntitledEditorModel} from 'vs/workbench/common/editor/untitledEditorModel';
|
||||
import {IInstantiationService} from 'vs/platform/instantiation/common/instantiation';
|
||||
import {ILifecycleService} from 'vs/platform/lifecycle/common/lifecycle';
|
||||
import {IWorkspaceContextService} from 'vs/platform/workspace/common/workspace';
|
||||
import {IModeService} from 'vs/editor/common/services/modeService';
|
||||
|
||||
import {ITextFileService} from 'vs/workbench/parts/files/common/files'; // TODO@Ben layer breaker
|
||||
|
||||
/**
|
||||
* An editor input to be used for untitled text buffers.
|
||||
*/
|
||||
@@ -36,7 +38,8 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
@IInstantiationService private instantiationService: IInstantiationService,
|
||||
@ILifecycleService private lifecycleService: ILifecycleService,
|
||||
@IWorkspaceContextService private contextService: IWorkspaceContextService,
|
||||
@IModeService private modeService: IModeService
|
||||
@IModeService private modeService: IModeService,
|
||||
@ITextFileService private textFileService: ITextFileService
|
||||
) {
|
||||
super();
|
||||
|
||||
@@ -74,6 +77,18 @@ export class UntitledEditorInput extends AbstractUntitledEditorInput {
|
||||
return null;
|
||||
}
|
||||
|
||||
public confirmSave(): ConfirmResult {
|
||||
return this.textFileService.confirmSave([this.resource]);
|
||||
}
|
||||
|
||||
public save(): TPromise<boolean> {
|
||||
return this.textFileService.save(this.resource);
|
||||
}
|
||||
|
||||
public revert(): TPromise<boolean> {
|
||||
return this.textFileService.revert(this.resource);
|
||||
}
|
||||
|
||||
public suggestFileName(): string {
|
||||
if (!this.hasAssociatedFilePath) {
|
||||
let mime = this.getMime();
|
||||
|
||||
Reference in New Issue
Block a user