untitled - mark as dirty when having initial contents

This commit is contained in:
Benjamin Pasero 2019-05-08 08:15:25 +02:00
parent 4064a323e1
commit 7b0eede51b
2 changed files with 11 additions and 1 deletions

View file

@ -146,7 +146,7 @@ export class UntitledEditorModel extends BaseTextEditorModel implements IEncodin
const hasBackup = !!backup;
// untitled associated to file path are dirty right away as well as untitled with content
this.setDirty(this._hasAssociatedFilePath || hasBackup);
this.setDirty(this._hasAssociatedFilePath || hasBackup || !!this.initialValue);
let untitledContents: ITextBufferFactory;
if (backup) {

View file

@ -173,6 +173,16 @@ suite('Workbench untitled editors', () => {
input.dispose();
});
test('Untitled with initial content is dirty', async () => {
const service = accessor.untitledEditorService;
const input = service.createOrGet(undefined, undefined, 'Hello World');
// dirty
const model = await input.resolve();
assert.ok(model.isDirty());
input.dispose();
});
test('Untitled created with files.defaultLanguage setting', () => {
const defaultLanguage = 'javascript';
const config = accessor.testConfigurationService;