mirror of
https://github.com/microsoft/vscode.git
synced 2026-06-06 07:35:52 +01:00
perf - introduce and use "soft" revert when closing all editors
This commit is contained in:
@@ -136,7 +136,6 @@ suite('Files - TextFileEditorModel', () => {
|
||||
test('Revert', function (done) {
|
||||
let eventCounter = 0;
|
||||
|
||||
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/index_async.txt'), 'utf8');
|
||||
|
||||
model.onDidStateChange(e => {
|
||||
@@ -162,6 +161,34 @@ suite('Files - TextFileEditorModel', () => {
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('Revert (soft)', function (done) {
|
||||
let eventCounter = 0;
|
||||
|
||||
const model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/index_async.txt'), 'utf8');
|
||||
|
||||
model.onDidStateChange(e => {
|
||||
if (e === StateChange.REVERTED) {
|
||||
eventCounter++;
|
||||
}
|
||||
});
|
||||
|
||||
model.load().done(() => {
|
||||
model.textEditorModel.setValue('foo');
|
||||
|
||||
assert.ok(model.isDirty());
|
||||
|
||||
return model.revert(true /* soft revert */).then(() => {
|
||||
assert.ok(!model.isDirty());
|
||||
assert.equal(model.textEditorModel.getValue(), 'foo');
|
||||
assert.equal(eventCounter, 1);
|
||||
|
||||
model.dispose();
|
||||
|
||||
done();
|
||||
});
|
||||
}, error => onError(error, done));
|
||||
});
|
||||
|
||||
test('File not modified error is handled gracefully', function (done) {
|
||||
const model: TextFileEditorModel = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/index_async.txt'), 'utf8');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user