@@ -7,12 +7,12 @@ import * as assert from 'assert';
7
7
import { EditorActivation , IResourceEditorInput } from 'vs/platform/editor/common/editor' ;
8
8
import { URI } from 'vs/base/common/uri' ;
9
9
import { Event } from 'vs/base/common/event' ;
10
- import { DEFAULT_EDITOR_ASSOCIATION , EditorCloseContext , EditorsOrder , IEditorCloseEvent , EditorInputWithOptions , IEditorPane , IResourceDiffEditorInput , isEditorInputWithOptions , IUntitledTextResourceEditorInput , IUntypedEditorInput , SideBySideEditor , isEditorInput } from 'vs/workbench/common/editor' ;
10
+ import { DEFAULT_EDITOR_ASSOCIATION , EditorCloseContext , EditorsOrder , IEditorCloseEvent , EditorInputWithOptions , IEditorPane , IResourceDiffEditorInput , isEditorInputWithOptions , IUntitledTextResourceEditorInput , IUntypedEditorInput , SideBySideEditor , isEditorInput , EditorInputCapabilities } from 'vs/workbench/common/editor' ;
11
11
import { workbenchInstantiationService , TestServiceAccessor , registerTestEditor , TestFileEditorInput , ITestInstantiationService , registerTestResourceEditor , registerTestSideBySideEditor , createEditorPart , registerTestFileEditor , TestTextFileEditor , TestSingletonFileEditorInput } from 'vs/workbench/test/browser/workbenchTestServices' ;
12
12
import { EditorService } from 'vs/workbench/services/editor/browser/editorService' ;
13
13
import { IEditorGroup , IEditorGroupsService , GroupDirection , GroupsArrangement } from 'vs/workbench/services/editor/common/editorGroupsService' ;
14
14
import { EditorPart } from 'vs/workbench/browser/parts/editor/editorPart' ;
15
- import { ACTIVE_GROUP , IEditorService , PreferredGroup , SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService' ;
15
+ import { ACTIVE_GROUP , IBaseSaveRevertAllEditorOptions , IEditorService , PreferredGroup , SIDE_GROUP } from 'vs/workbench/services/editor/common/editorService' ;
16
16
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors' ;
17
17
import { FileEditorInput } from 'vs/workbench/contrib/files/browser/editors/fileEditorInput' ;
18
18
import { timeout } from 'vs/base/common/async' ;
@@ -2173,6 +2173,61 @@ suite('EditorService', () => {
2173
2173
assert . strictEqual ( sameInput1 . gotSaved , true ) ;
2174
2174
} ) ;
2175
2175
2176
+ test ( 'saveAll, revertAll untitled (exclude untitled)' , async function ( ) {
2177
+ await testSaveRevertUntitled ( { } , false , false ) ;
2178
+ await testSaveRevertUntitled ( { includeUntitled : false } , false , false ) ;
2179
+ } ) ;
2180
+
2181
+ test ( 'saveAll, revertAll untitled (include untitled)' , async function ( ) {
2182
+ await testSaveRevertUntitled ( { includeUntitled : true } , true , false ) ;
2183
+ await testSaveRevertUntitled ( { includeUntitled : { includeScratchpad : false } } , true , false ) ;
2184
+ } ) ;
2185
+
2186
+ test ( 'saveAll, revertAll untitled (include scratchpad)' , async function ( ) {
2187
+ await testSaveRevertUntitled ( { includeUntitled : { includeScratchpad : true } } , true , true ) ;
2188
+ } ) ;
2189
+
2190
+ async function testSaveRevertUntitled ( options : IBaseSaveRevertAllEditorOptions , expectUntitled : boolean , expectScratchpad : boolean ) {
2191
+ const [ , service ] = await createEditorService ( ) ;
2192
+ const input1 = new TestFileEditorInput ( URI . parse ( 'my://resource1' ) , TEST_EDITOR_INPUT_ID ) ;
2193
+ input1 . dirty = true ;
2194
+ const untitledInput = new TestFileEditorInput ( URI . parse ( 'my://resource2' ) , TEST_EDITOR_INPUT_ID ) ;
2195
+ untitledInput . dirty = true ;
2196
+ untitledInput . capabilities = EditorInputCapabilities . Untitled ;
2197
+ const scratchpadInput = new TestFileEditorInput ( URI . parse ( 'my://resource3' ) , TEST_EDITOR_INPUT_ID ) ;
2198
+ scratchpadInput . modified = true ;
2199
+ scratchpadInput . capabilities = EditorInputCapabilities . Scratchpad | EditorInputCapabilities . Untitled ;
2200
+
2201
+ await service . openEditor ( input1 , { pinned : true , sticky : true } ) ;
2202
+ await service . openEditor ( untitledInput , { pinned : true } ) ;
2203
+ await service . openEditor ( scratchpadInput , { pinned : true } ) ;
2204
+
2205
+ const revertRes = await service . revertAll ( options ) ;
2206
+ assert . strictEqual ( revertRes , true ) ;
2207
+ assert . strictEqual ( input1 . gotReverted , true ) ;
2208
+ assert . strictEqual ( untitledInput . gotReverted , expectUntitled ) ;
2209
+ assert . strictEqual ( scratchpadInput . gotReverted , expectScratchpad ) ;
2210
+
2211
+ input1 . gotSaved = false ;
2212
+ untitledInput . gotSavedAs = false ;
2213
+ scratchpadInput . gotReverted = false ;
2214
+
2215
+ input1 . gotSaved = false ;
2216
+ untitledInput . gotSavedAs = false ;
2217
+ scratchpadInput . gotReverted = false ;
2218
+
2219
+ input1 . dirty = true ;
2220
+ untitledInput . dirty = true ;
2221
+ scratchpadInput . modified = true ;
2222
+
2223
+ const saveRes = await service . saveAll ( options ) ;
2224
+ assert . strictEqual ( saveRes . success , true ) ;
2225
+ assert . strictEqual ( saveRes . editors . length , expectScratchpad ? 3 : expectUntitled ? 2 : 1 ) ;
2226
+ assert . strictEqual ( input1 . gotSaved , true ) ;
2227
+ assert . strictEqual ( untitledInput . gotSaved , expectUntitled ) ;
2228
+ assert . strictEqual ( scratchpadInput . gotSaved , expectScratchpad ) ;
2229
+ }
2230
+
2176
2231
test ( 'file delete closes editor' , async function ( ) {
2177
2232
return testFileDeleteEditorClose ( false ) ;
2178
2233
} ) ;
0 commit comments